Skip to content

Commit 27e94e8

Browse files
authored
feat: config settings to use different bundlers (#5837)
Introduces ability to configure other bundlers such as rspack, vite, etc. while still keeping a webpack default.
1 parent a1c39f6 commit 27e94e8

File tree

7 files changed

+180
-66
lines changed

7 files changed

+180
-66
lines changed

lib/commands/embedding/embed.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class EmbedCommand extends PrepareCommand implements ICommand {
2424

2525
private $logger: ILogger,
2626
private $fs: IFileSystem,
27-
private $projectConfigService: IProjectConfigService
27+
private $projectConfigService: IProjectConfigService,
2828
) {
2929
super(
3030
$options,
@@ -34,7 +34,7 @@ export class EmbedCommand extends PrepareCommand implements ICommand {
3434
$platformCommandParameter,
3535
$platformsDataService,
3636
$prepareDataService,
37-
$migrateController
37+
$migrateController,
3838
);
3939
}
4040

@@ -59,8 +59,8 @@ export class EmbedCommand extends PrepareCommand implements ICommand {
5959
hostProjectPath,
6060
)} (resolved to: ${color.styleText(
6161
["yellow", "dim"],
62-
resolvedHostProjectPath
63-
)}) does not exist.`
62+
resolvedHostProjectPath,
63+
)}) does not exist.`,
6464
);
6565
return;
6666
}
@@ -90,7 +90,7 @@ export class EmbedCommand extends PrepareCommand implements ICommand {
9090
if (!args[1]) {
9191
const hostProjectPath = this.getEmbedConfigForKey(
9292
"hostProjectPath",
93-
platform
93+
platform,
9494
);
9595
if (hostProjectPath) {
9696
args[1] = hostProjectPath;
@@ -100,7 +100,7 @@ export class EmbedCommand extends PrepareCommand implements ICommand {
100100
if (!args[2]) {
101101
const hostProjectModuleName = this.getEmbedConfigForKey(
102102
"hostProjectModuleName",
103-
platform
103+
platform,
104104
);
105105
if (hostProjectModuleName) {
106106
args[2] = hostProjectModuleName;
@@ -120,7 +120,7 @@ export class EmbedCommand extends PrepareCommand implements ICommand {
120120
// get the embed.<platform>.<key> value, or fallback to embed.<key> value
121121
return this.$projectConfigService.getValue(
122122
`embed.${platform}.${key}`,
123-
this.$projectConfigService.getValue(`embed.${key}`)
123+
this.$projectConfigService.getValue(`embed.${key}`),
124124
);
125125
}
126126
}

lib/commands/post-install.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class PostInstallCliCommand implements ICommand {
1818
private $settingsService: ISettingsService,
1919
private $analyticsService: IAnalyticsService,
2020
private $logger: ILogger,
21-
private $hostInfo: IHostInfo
21+
private $hostInfo: IHostInfo,
2222
) {}
2323

2424
public disableAnalytics = true;
@@ -35,7 +35,7 @@ export class PostInstallCliCommand implements ICommand {
3535
// TODO: Check if this is the correct place, probably we should set this at the end of the command.
3636
await this.$fs.setCurrentUserAsOwner(
3737
this.$settingsService.getProfileDir(),
38-
process.env.SUDO_USER
38+
process.env.SUDO_USER,
3939
);
4040
}
4141
}
@@ -66,7 +66,7 @@ export class PostInstallCliCommand implements ICommand {
6666

6767
this.$logger.info("");
6868
this.$logger.printMarkdown(
69-
"If you have any questions, check Stack Overflow: `https://stackoverflow.com/questions/tagged/nativescript` and our public Discord channel: `https://nativescript.org/discord`"
69+
"If you have any questions, check Stack Overflow: `https://stackoverflow.com/questions/tagged/nativescript` and our public Discord channel: `https://nativescript.org/discord`",
7070
);
7171
}
7272
}

lib/commands/typings.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class TypingsCommand implements ICommand {
2020
private $childProcess: IChildProcess,
2121
private $hostInfo: IHostInfo,
2222
private $staticConfig: IStaticConfig,
23-
private $prompter: IPrompter
23+
private $prompter: IPrompter,
2424
) {}
2525

2626
public async execute(args: string[]): Promise<void> {
@@ -35,15 +35,15 @@ export class TypingsCommand implements ICommand {
3535
if (this.$options.copyTo) {
3636
this.$fs.copyFile(
3737
path.resolve(this.$projectData.projectDir, "typings"),
38-
this.$options.copyTo
38+
this.$options.copyTo,
3939
);
4040
typingsFolder = this.$options.copyTo;
4141
}
4242

4343
if (result !== false) {
4444
this.$logger.info(
4545
"Typings have been generated in the following directory:",
46-
typingsFolder
46+
typingsFolder,
4747
);
4848
}
4949
}
@@ -56,7 +56,7 @@ export class TypingsCommand implements ICommand {
5656

5757
private async resolveGradleDependencies(target: string) {
5858
const gradleHome = path.resolve(
59-
process.env.GRADLE_USER_HOME ?? path.join(homedir(), `/.gradle`)
59+
process.env.GRADLE_USER_HOME ?? path.join(homedir(), `/.gradle`),
6060
);
6161
const gradleFiles = path.resolve(gradleHome, "caches/modules-2/files-2.1/");
6262

@@ -92,7 +92,7 @@ export class TypingsCommand implements ICommand {
9292

9393
const choices = await this.$prompter.promptForChoice(
9494
`Select dependencies to generate typings for (${color.greenBright(
95-
target
95+
target,
9696
)})`,
9797
items
9898
.sort((a, b) => {
@@ -118,7 +118,7 @@ export class TypingsCommand implements ICommand {
118118
true,
119119
{
120120
optionsPerPage: process.stdout.rows - 6, // 6 lines are taken up by the instructions
121-
} as Partial<PromptObject>
121+
} as Partial<PromptObject>,
122122
);
123123

124124
this.$logger.clearScreen();
@@ -139,7 +139,7 @@ export class TypingsCommand implements ICommand {
139139
} catch (err) {
140140
this.$logger.trace(
141141
`Failed to resolve gradle dependencies for target "${target}"`,
142-
err
142+
err,
143143
);
144144
}
145145
}
@@ -151,29 +151,29 @@ export class TypingsCommand implements ICommand {
151151
"No .jar or .aar file specified. Please specify at least one of the following:",
152152
" - path to .jar file with --jar <jar>",
153153
" - path to .aar file with --aar <aar>",
154-
].join("\n")
154+
].join("\n"),
155155
);
156156
return false;
157157
}
158158

159159
this.$fs.ensureDirectoryExists(
160-
path.resolve(this.$projectData.projectDir, "typings", "android")
160+
path.resolve(this.$projectData.projectDir, "typings", "android"),
161161
);
162162

163163
const dtsGeneratorPath = path.resolve(
164164
this.$projectData.projectDir,
165165
"platforms",
166166
"android",
167167
"build-tools",
168-
"dts-generator.jar"
168+
"dts-generator.jar",
169169
);
170170
if (!this.$fs.exists(dtsGeneratorPath)) {
171171
this.$logger.warn("No platforms folder found, preparing project now...");
172172
await this.$childProcess.spawnFromEvent(
173173
this.$hostInfo.isWindows ? "ns.cmd" : "ns",
174174
["prepare", "android"],
175175
"exit",
176-
{ stdio: "inherit", shell: this.$hostInfo.isWindows }
176+
{ stdio: "inherit", shell: this.$hostInfo.isWindows },
177177
);
178178
}
179179

@@ -206,7 +206,7 @@ export class TypingsCommand implements ICommand {
206206
path.resolve(this.$projectData.projectDir, "typings", "android"),
207207
],
208208
"exit",
209-
{ stdio: "inherit" }
209+
{ stdio: "inherit" },
210210
);
211211
}
212212

@@ -216,7 +216,7 @@ export class TypingsCommand implements ICommand {
216216
}
217217

218218
this.$fs.ensureDirectoryExists(
219-
path.resolve(this.$projectData.projectDir, "typings", "ios")
219+
path.resolve(this.$projectData.projectDir, "typings", "ios"),
220220
);
221221

222222
await this.$childProcess.spawnFromEvent(
@@ -229,11 +229,11 @@ export class TypingsCommand implements ICommand {
229229
TNS_TYPESCRIPT_DECLARATIONS_PATH: path.resolve(
230230
this.$projectData.projectDir,
231231
"typings",
232-
"ios"
232+
"ios",
233233
),
234234
},
235235
stdio: "inherit",
236-
}
236+
},
237237
);
238238
}
239239
}

lib/common/header.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ export function printHeader() {
3131

3232
console.info(" " + color.dim("┌" + "─".repeat(width - 1) + "┐"));
3333
console.info(
34-
" " + header + " ".repeat(width - headerLength) + color.dim("│")
34+
" " + header + " ".repeat(width - headerLength) + color.dim("│"),
3535
);
3636
console.info(
37-
" " + tagLine + " ".repeat(width - tagLineLength) + color.dim("│")
37+
" " + tagLine + " ".repeat(width - tagLineLength) + color.dim("│"),
3838
);
3939
console.info(" " + color.dim("└" + "─".repeat(width - 1) + "┘"));
4040
}

lib/helpers/key-command-helper.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,18 @@ export default class KeyCommandHelper implements IKeyCommandHelper {
115115
[
116116
"",
117117
` The CLI is ${color.underline(
118-
`interactive`
118+
`interactive`,
119119
)}, you can press the following keys any time (make sure the terminal has focus).`,
120120
"",
121121
...commandHelp,
122122
"",
123-
].join("\n")
123+
].join("\n"),
124124
);
125125
}
126126

127127
public attachKeyCommands(
128128
platform: IKeyCommandPlatform,
129-
processType: SupportedProcessType
129+
processType: SupportedProcessType,
130130
) {
131131
this.processType = processType;
132132
this.platform = platform;

lib/services/analytics-settings-service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class AnalyticsSettingsService implements IAnalyticsSettingsService {
1919
private $staticConfig: IStaticConfig,
2020
private $hostInfo: IHostInfo,
2121
private $osInfo: IOsInfo,
22-
private $logger: ILogger
22+
private $logger: ILogger,
2323
) {}
2424

2525
public async canDoRequest(): Promise<boolean> {
@@ -33,7 +33,7 @@ class AnalyticsSettingsService implements IAnalyticsSettingsService {
3333
@exported("analyticsSettingsService")
3434
public getClientId(): Promise<string> {
3535
return this.getSettingValueOrDefault(
36-
this.$staticConfig.ANALYTICS_INSTALLATION_ID_SETTING_NAME
36+
this.$staticConfig.ANALYTICS_INSTALLATION_ID_SETTING_NAME,
3737
);
3838
}
3939

@@ -54,11 +54,11 @@ class AnalyticsSettingsService implements IAnalyticsSettingsService {
5454

5555
public async setUserSessionsCount(
5656
count: number,
57-
projectName: string
57+
projectName: string,
5858
): Promise<void> {
5959
return this.$userSettingsService.saveSetting<number>(
6060
this.getSessionsProjectKey(projectName),
61-
count
61+
count,
6262
);
6363
}
6464

0 commit comments

Comments
 (0)