Skip to content

Commit 773e68e

Browse files
committed
feat: legacy-peer option on ns create
1 parent 61ca879 commit 773e68e

File tree

11 files changed

+175
-138
lines changed

11 files changed

+175
-138
lines changed

lib/bun-package-manager.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class BunPackageManager extends BasePackageManager {
2525
$hostInfo: IHostInfo,
2626
private $logger: ILogger,
2727
private $httpClient: Server.IHttpClient,
28-
$pacoteService: IPacoteService
28+
$pacoteService: IPacoteService,
2929
) {
3030
super($childProcess, $fs, $hostInfo, $pacoteService, "bun");
3131
}
@@ -34,11 +34,12 @@ export class BunPackageManager extends BasePackageManager {
3434
public async install(
3535
packageName: string,
3636
pathToSave: string,
37-
config: INodePackageManagerInstallOptions
37+
config: INodePackageManagerInstallOptions,
3838
): Promise<INpmInstallResultInfo> {
3939
if (config.disableNpmInstall) {
4040
return;
4141
}
42+
delete (config as any).legacyPeers;
4243
if (config.ignoreScripts) {
4344
config["ignore-scripts"] = true;
4445
}
@@ -60,7 +61,7 @@ export class BunPackageManager extends BasePackageManager {
6061
const result = await this.processPackageManagerInstall(
6162
packageName,
6263
params,
63-
{ cwd, isInstallingAllDependencies }
64+
{ cwd, isInstallingAllDependencies },
6465
);
6566
return result;
6667
} catch (err) {
@@ -74,7 +75,7 @@ export class BunPackageManager extends BasePackageManager {
7475
public async uninstall(
7576
packageName: string,
7677
config?: any,
77-
cwd?: string
78+
cwd?: string,
7879
): Promise<string> {
7980
const flags = this.getFlagsString(config, false);
8081
return this.$childProcess.exec(`bun remove ${packageName} ${flags}`, {
@@ -91,7 +92,7 @@ export class BunPackageManager extends BasePackageManager {
9192
let viewResult: any;
9293
try {
9394
viewResult = await this.$childProcess.exec(
94-
`npm view ${packageName} ${flags}`
95+
`npm view ${packageName} ${flags}`,
9596
);
9697
} catch (e) {
9798
this.$errors.fail(e.message);
@@ -119,7 +120,7 @@ export class BunPackageManager extends BasePackageManager {
119120
// https://github.com/npms-io/npms-api/issues/112. Better to switch to
120121
// https://registry.npmjs.org/<query>
121122
const httpRequestResult = await this.$httpClient.httpRequest(
122-
`https://api.npms.io/v2/search?q=keywords:${keyword}`
123+
`https://api.npms.io/v2/search?q=keywords:${keyword}`,
123124
);
124125
const result: INpmsResult = JSON.parse(httpRequestResult.body);
125126
return result;
@@ -132,15 +133,15 @@ export class BunPackageManager extends BasePackageManager {
132133
const registry = await this.$childProcess.exec(`npm config get registry`);
133134
const url = registry.trim() + packageName;
134135
this.$logger.trace(
135-
`Trying to get data from npm registry for package ${packageName}, url is: ${url}`
136+
`Trying to get data from npm registry for package ${packageName}, url is: ${url}`,
136137
);
137138
const responseData = (await this.$httpClient.httpRequest(url)).body;
138139
this.$logger.trace(
139-
`Successfully received data from npm registry for package ${packageName}. Response data is: ${responseData}`
140+
`Successfully received data from npm registry for package ${packageName}. Response data is: ${responseData}`,
140141
);
141142
const jsonData = JSON.parse(responseData);
142143
this.$logger.trace(
143-
`Successfully parsed data from npm registry for package ${packageName}.`
144+
`Successfully parsed data from npm registry for package ${packageName}.`,
144145
);
145146
return jsonData;
146147
}

lib/commands/create-project.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class CreateProjectCommand implements ICommand {
3535
private $errors: IErrors,
3636
private $options: IOptions,
3737
private $prompter: IPrompter,
38-
private $stringParameter: ICommandParameter
38+
private $stringParameter: ICommandParameter,
3939
) {}
4040

4141
public async execute(args: string[]): Promise<void> {
@@ -55,7 +55,7 @@ export class CreateProjectCommand implements ICommand {
5555
this.$options.template
5656
) {
5757
this.$errors.failWithHelp(
58-
"You cannot use a flavor option like --ng, --vue, --react, --solid, --svelte, --tsc and --js together with --template."
58+
"You cannot use a flavor option like --ng, --vue, --react, --solid, --svelte, --tsc and --js together with --template.",
5959
);
6060
}
6161

@@ -115,7 +115,7 @@ export class CreateProjectCommand implements ICommand {
115115
this.printInteractiveCreationIntroIfNeeded();
116116
projectName = await this.$prompter.getString(
117117
`${getNextInteractiveAdverb()}, what will be the name of your app?`,
118-
{ allowEmpty: false }
118+
{ allowEmpty: false },
119119
);
120120
this.$logger.info();
121121
}
@@ -130,7 +130,7 @@ export class CreateProjectCommand implements ICommand {
130130
this.printInteractiveCreationIntroIfNeeded();
131131
selectedTemplate = await this.interactiveFlavorAndTemplateSelection(
132132
getNextInteractiveAdverb(),
133-
getNextInteractiveAdverb()
133+
getNextInteractiveAdverb(),
134134
);
135135
}
136136

@@ -142,17 +142,18 @@ export class CreateProjectCommand implements ICommand {
142142
// its already validated above
143143
force: true,
144144
ignoreScripts: this.$options.ignoreScripts,
145+
legacyPeerDeps: this.$options.legacyPeerDeps,
145146
});
146147
}
147148

148149
private async interactiveFlavorAndTemplateSelection(
149150
flavorAdverb: string,
150-
templateAdverb: string
151+
templateAdverb: string,
151152
) {
152153
const selectedFlavor = await this.interactiveFlavorSelection(flavorAdverb);
153154
const selectedTemplate: string = await this.interactiveTemplateSelection(
154155
selectedFlavor,
155-
templateAdverb
156+
templateAdverb,
156157
);
157158

158159
return selectedTemplate;
@@ -191,7 +192,7 @@ export class CreateProjectCommand implements ICommand {
191192
key: constants.JsFlavorName,
192193
description: "Use NativeScript without any framework",
193194
},
194-
]
195+
],
195196
);
196197
return flavorSelection;
197198
}
@@ -210,7 +211,7 @@ can skip this prompt next time using the --template option, or using --ng, --rea
210211

211212
private async interactiveTemplateSelection(
212213
flavorSelection: string,
213-
adverb: string
214+
adverb: string,
214215
) {
215216
const selectedFlavorTemplates: {
216217
key?: string;
@@ -255,10 +256,10 @@ can skip this prompt next time using the --template option, or using --ng, --rea
255256
});
256257
const selectedTemplateKey = await this.$prompter.promptForDetailedChoice(
257258
`${adverb}, which template would you like to start from:`,
258-
templateChoices
259+
templateChoices,
259260
);
260261
selectedTemplate = selectedFlavorTemplates.find(
261-
(t) => t.key === selectedTemplateKey
262+
(t) => t.key === selectedTemplateKey,
262263
).value;
263264
} else {
264265
selectedTemplate = selectedFlavorTemplates[0].value;
@@ -472,14 +473,14 @@ can skip this prompt next time using the --template option, or using --ng, --rea
472473
].join(" "),
473474
"",
474475
`Now you can navigate to your project with ${color.cyan(
475-
`cd ${relativePath}`
476+
`cd ${relativePath}`,
476477
)} and then:`,
477478
"",
478479
...runDebugNotes,
479480
``,
480481
`For more options consult the docs or run ${color.green("ns --help")}`,
481482
"",
482-
].join("\n")
483+
].join("\n"),
483484
);
484485
// todo: add back ns preview
485486
// this.$logger.printMarkdown(

0 commit comments

Comments
 (0)