1
1
#!/usr/bin/env node
2
2
3
+ import { log } from "@clack/prompts" ;
4
+ import { Metafile } from "esbuild" ;
3
5
import { join } from "node:path" ;
6
+ import terminalLink from "terminal-link" ;
4
7
5
- import { ReadConfigResult } from "../src/utilities/configFiles.js" ;
6
- import { writeJSONFile } from "../src/utilities/fileSystem.js" ;
7
- import { logger } from "../src/utilities/logger.js" ;
8
- import { JavascriptProject } from "../src/utilities/javascriptProject.js" ;
8
+ import { SkipLoggingError } from "../src/cli/common.js" ;
9
9
import {
10
10
copyAdditionalFiles ,
11
11
resolveDependencies ,
12
12
resolveRequiredDependencies ,
13
13
} from "../src/commands/deploy.js" ;
14
- import terminalLink from "terminal-link" ;
15
- import { SkipLoggingError } from "../src/cli/common.js" ;
16
- import { log } from "@clack/prompts" ;
17
- import { Metafile } from "esbuild" ;
14
+ import { ReadConfigResult } from "../src/utilities/configFiles.js" ;
15
+ import { writeJSONFile } from "../src/utilities/fileSystem.js" ;
16
+ import { PackageManager } from "../src/utilities/getUserPackageManager.js" ;
17
+ import { JavascriptProject } from "../src/utilities/javascriptProject.js" ;
18
+ import { logger } from "../src/utilities/logger.js" ;
18
19
19
20
type HandleDependenciesOptions = {
20
21
entryPointMetaOutput : Metafile [ "outputs" ] [ "out/stdin.js" ] ;
21
22
metaOutput: Metafile [ "outputs" ] [ "out/stdin.js" ] ;
23
+ packageManager: PackageManager ;
22
24
resolvedConfig: ReadConfigResult ;
23
25
tempDir: string ;
24
26
} ;
25
27
28
+ class JavascriptProjectLocal extends JavascriptProject {
29
+ constructor (
30
+ projectPath : string ,
31
+ private overridenPackageManager : PackageManager
32
+ ) {
33
+ super ( projectPath ) ;
34
+ }
35
+
36
+ async getPackageManager ( ) : Promise < PackageManager > {
37
+ return Promise . resolve ( this . overridenPackageManager ) ;
38
+ }
39
+ }
40
+
26
41
export async function handleDependencies ( options : HandleDependenciesOptions ) {
27
42
if ( options . resolvedConfig . status === "error" ) {
28
43
throw new Error ( "cannot resolve config" ) ;
29
44
}
30
45
const {
31
46
entryPointMetaOutput,
32
47
metaOutput,
48
+ packageManager,
33
49
resolvedConfig : { config } ,
34
50
tempDir,
35
51
} = options ;
@@ -43,7 +59,8 @@ export async function handleDependencies(options: HandleDependenciesOptions) {
43
59
// Get all the required dependencies from the metaOutputs and save them to /tmp/dir/package.json
44
60
const allImports = [ ...metaOutput . imports , ...entryPointMetaOutput . imports ] ;
45
61
46
- const javascriptProject = new JavascriptProject ( config . projectDir ) ;
62
+ // const javascriptProject = new JavascriptProject(config.projectDir);
63
+ const javascriptProject = new JavascriptProjectLocal ( config . projectDir , packageManager ) ;
47
64
48
65
const dependencies = await resolveRequiredDependencies ( allImports , config , javascriptProject ) ;
49
66
0 commit comments