Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions lib/bun-package-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class BunPackageManager extends BasePackageManager {
$hostInfo: IHostInfo,
private $logger: ILogger,
private $httpClient: Server.IHttpClient,
$pacoteService: IPacoteService
$pacoteService: IPacoteService,
) {
super($childProcess, $fs, $hostInfo, $pacoteService, "bun");
}
Expand All @@ -34,11 +34,12 @@ export class BunPackageManager extends BasePackageManager {
public async install(
packageName: string,
pathToSave: string,
config: INodePackageManagerInstallOptions
config: INodePackageManagerInstallOptions,
): Promise<INpmInstallResultInfo> {
if (config.disableNpmInstall) {
return;
}
delete (config as any).legacyPeers;
if (config.ignoreScripts) {
config["ignore-scripts"] = true;
}
Expand All @@ -60,7 +61,7 @@ export class BunPackageManager extends BasePackageManager {
const result = await this.processPackageManagerInstall(
packageName,
params,
{ cwd, isInstallingAllDependencies }
{ cwd, isInstallingAllDependencies },
);
return result;
} catch (err) {
Expand All @@ -74,7 +75,7 @@ export class BunPackageManager extends BasePackageManager {
public async uninstall(
packageName: string,
config?: any,
cwd?: string
cwd?: string,
): Promise<string> {
const flags = this.getFlagsString(config, false);
return this.$childProcess.exec(`bun remove ${packageName} ${flags}`, {
Expand All @@ -91,7 +92,7 @@ export class BunPackageManager extends BasePackageManager {
let viewResult: any;
try {
viewResult = await this.$childProcess.exec(
`npm view ${packageName} ${flags}`
`npm view ${packageName} ${flags}`,
);
} catch (e) {
this.$errors.fail(e.message);
Expand Down Expand Up @@ -119,7 +120,7 @@ export class BunPackageManager extends BasePackageManager {
// https://github.com/npms-io/npms-api/issues/112. Better to switch to
// https://registry.npmjs.org/<query>
const httpRequestResult = await this.$httpClient.httpRequest(
`https://api.npms.io/v2/search?q=keywords:${keyword}`
`https://api.npms.io/v2/search?q=keywords:${keyword}`,
);
const result: INpmsResult = JSON.parse(httpRequestResult.body);
return result;
Expand All @@ -132,15 +133,15 @@ export class BunPackageManager extends BasePackageManager {
const registry = await this.$childProcess.exec(`npm config get registry`);
const url = registry.trim() + packageName;
this.$logger.trace(
`Trying to get data from npm registry for package ${packageName}, url is: ${url}`
`Trying to get data from npm registry for package ${packageName}, url is: ${url}`,
);
const responseData = (await this.$httpClient.httpRequest(url)).body;
this.$logger.trace(
`Successfully received data from npm registry for package ${packageName}. Response data is: ${responseData}`
`Successfully received data from npm registry for package ${packageName}. Response data is: ${responseData}`,
);
const jsonData = JSON.parse(responseData);
this.$logger.trace(
`Successfully parsed data from npm registry for package ${packageName}.`
`Successfully parsed data from npm registry for package ${packageName}.`,
);
return jsonData;
}
Expand Down
28 changes: 16 additions & 12 deletions lib/commands/create-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class CreateProjectCommand implements ICommand {
private $errors: IErrors,
private $options: IOptions,
private $prompter: IPrompter,
private $stringParameter: ICommandParameter
private $stringParameter: ICommandParameter,
) {}

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

Expand Down Expand Up @@ -115,7 +115,7 @@ export class CreateProjectCommand implements ICommand {
this.printInteractiveCreationIntroIfNeeded();
projectName = await this.$prompter.getString(
`${getNextInteractiveAdverb()}, what will be the name of your app?`,
{ allowEmpty: false }
{ allowEmpty: false },
);
this.$logger.info();
}
Expand All @@ -130,10 +130,13 @@ export class CreateProjectCommand implements ICommand {
this.printInteractiveCreationIntroIfNeeded();
selectedTemplate = await this.interactiveFlavorAndTemplateSelection(
getNextInteractiveAdverb(),
getNextInteractiveAdverb()
getNextInteractiveAdverb(),
);
}

const legacyPeerDeps =
this.$options.legacyPeerDeps || (this.$options as any).legacyPeers;

this.createdProjectData = await this.$projectService.createProject({
projectName: projectName,
template: selectedTemplate,
Expand All @@ -142,17 +145,18 @@ export class CreateProjectCommand implements ICommand {
// its already validated above
force: true,
ignoreScripts: this.$options.ignoreScripts,
legacyPeerDeps,
});
}

private async interactiveFlavorAndTemplateSelection(
flavorAdverb: string,
templateAdverb: string
templateAdverb: string,
) {
const selectedFlavor = await this.interactiveFlavorSelection(flavorAdverb);
const selectedTemplate: string = await this.interactiveTemplateSelection(
selectedFlavor,
templateAdverb
templateAdverb,
);

return selectedTemplate;
Expand Down Expand Up @@ -191,7 +195,7 @@ export class CreateProjectCommand implements ICommand {
key: constants.JsFlavorName,
description: "Use NativeScript without any framework",
},
]
],
);
return flavorSelection;
}
Expand All @@ -210,7 +214,7 @@ can skip this prompt next time using the --template option, or using --ng, --rea

private async interactiveTemplateSelection(
flavorSelection: string,
adverb: string
adverb: string,
) {
const selectedFlavorTemplates: {
key?: string;
Expand Down Expand Up @@ -255,10 +259,10 @@ can skip this prompt next time using the --template option, or using --ng, --rea
});
const selectedTemplateKey = await this.$prompter.promptForDetailedChoice(
`${adverb}, which template would you like to start from:`,
templateChoices
templateChoices,
);
selectedTemplate = selectedFlavorTemplates.find(
(t) => t.key === selectedTemplateKey
(t) => t.key === selectedTemplateKey,
).value;
} else {
selectedTemplate = selectedFlavorTemplates[0].value;
Expand Down Expand Up @@ -472,14 +476,14 @@ can skip this prompt next time using the --template option, or using --ng, --rea
].join(" "),
"",
`Now you can navigate to your project with ${color.cyan(
`cd ${relativePath}`
`cd ${relativePath}`,
)} and then:`,
"",
...runDebugNotes,
``,
`For more options consult the docs or run ${color.green("ns --help")}`,
"",
].join("\n")
].join("\n"),
);
// todo: add back ns preview
// this.$logger.printMarkdown(
Expand Down
Loading