Skip to content

Commit 79df7dd

Browse files
committed
chore: TypeScript 5.7 + dep updates
1 parent 105f477 commit 79df7dd

38 files changed

+7283
-7839
lines changed

Gruntfile.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ const childProcess = require("child_process");
22
const EOL = require("os").EOL;
33
const path = require("path");
44
const now = new Date().toISOString();
5-
const latestVersion = require('latest-version');
5+
const latestVersion = require('latest-version').default;
6+
67

78
const ENVIRONMENTS = {
89
live: "live",

lib/commands/clean.ts

+28-28
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function bytesToHumanReadable(bytes: number): string {
4747
function promiseMap<T>(
4848
values: T[],
4949
mapper: (value: T) => Promise<void>,
50-
concurrency = 10
50+
concurrency = 10,
5151
) {
5252
let index = 0;
5353
let pending = 0;
@@ -89,7 +89,7 @@ export class CleanCommand implements ICommand {
8989
private $logger: ILogger,
9090
private $options: IOptions,
9191
private $childProcess: IChildProcess,
92-
private $staticConfig: IStaticConfig
92+
private $staticConfig: IStaticConfig,
9393
) {}
9494

9595
public async execute(args: string[]): Promise<void> {
@@ -117,7 +117,7 @@ export class CleanCommand implements ICommand {
117117
const overridePathsToClean =
118118
this.$projectConfigService.getValue("cli.pathsToClean");
119119
const additionalPaths = this.$projectConfigService.getValue(
120-
"cli.additionalPathsToClean"
120+
"cli.additionalPathsToClean",
121121
);
122122

123123
// allow overriding default paths to clean
@@ -147,8 +147,8 @@ export class CleanCommand implements ICommand {
147147
stats: Object.fromEntries(res.stats.entries()),
148148
},
149149
null,
150-
2
151-
)
150+
2,
151+
),
152152
);
153153

154154
return;
@@ -169,7 +169,7 @@ export class CleanCommand implements ICommand {
169169
}
170170

171171
const shouldScan = await this.$prompter.confirm(
172-
"No project found in the current directory. Would you like to scan for all projects in sub-directories instead?"
172+
"No project found in the current directory. Would you like to scan for all projects in sub-directories instead?",
173173
);
174174

175175
if (!shouldScan) {
@@ -184,7 +184,7 @@ export class CleanCommand implements ICommand {
184184
const updateProgress = () => {
185185
const current = color.grey(`${computed}/${paths.length}`);
186186
spinner.start(
187-
`Gathering cleanable sizes. This may take a while... ${current}`
187+
`Gathering cleanable sizes. This may take a while... ${current}`,
188188
);
189189
};
190190

@@ -201,7 +201,7 @@ export class CleanCommand implements ICommand {
201201
`node ${this.$staticConfig.cliBinPath} clean --dry-run --json --disable-analytics`,
202202
{
203203
cwd: p,
204-
}
204+
},
205205
)
206206
.then((res) => {
207207
const paths: Record<string, number> = JSON.parse(res).stats;
@@ -211,7 +211,7 @@ export class CleanCommand implements ICommand {
211211
this.$logger.trace(
212212
"Failed to get project size for %s, Error is:",
213213
p,
214-
err
214+
err,
215215
);
216216
return -1;
217217
})
@@ -225,7 +225,7 @@ export class CleanCommand implements ICommand {
225225
updateProgress();
226226
});
227227
},
228-
os.cpus().length
228+
os.cpus().length,
229229
);
230230

231231
spinner.clear();
@@ -241,7 +241,7 @@ export class CleanCommand implements ICommand {
241241
`Found ${
242242
projects.size
243243
} cleanable project(s) with a total size of: ${color.green(
244-
bytesToHumanReadable(totalSize)
244+
bytesToHumanReadable(totalSize),
245245
)}. Select projects to clean`,
246246
Array.from(projects.keys()).map((p) => {
247247
const size = projects.get(p);
@@ -260,21 +260,21 @@ export class CleanCommand implements ICommand {
260260
true,
261261
{
262262
optionsPerPage: process.stdout.rows - 6, // 6 lines are taken up by the instructions
263-
} as Partial<PromptObject>
263+
} as Partial<PromptObject>,
264264
);
265265
this.$logger.clearScreen();
266266

267267
spinner.warn(
268268
`This will run "${color.yellow(
269-
`ns clean`
269+
`ns clean`,
270270
)}" in all the selected projects and ${color.red.bold(
271-
"delete files from your system"
272-
)}!`
271+
"delete files from your system",
272+
)}!`,
273273
);
274274
spinner.warn(`This action cannot be undone!`);
275275

276276
let confirmed = await this.$prompter.confirm(
277-
"Are you sure you want to clean the selected projects?"
277+
"Are you sure you want to clean the selected projects?",
278278
);
279279
if (!confirmed) {
280280
return;
@@ -287,7 +287,7 @@ export class CleanCommand implements ICommand {
287287
const currentPath = pathsToClean[i];
288288

289289
spinner.start(
290-
`Cleaning ${color.cyan(currentPath)}... ${i + 1}/${pathsToClean.length}`
290+
`Cleaning ${color.cyan(currentPath)}... ${i + 1}/${pathsToClean.length}`,
291291
);
292292

293293
const ok = await this.$childProcess
@@ -297,7 +297,7 @@ export class CleanCommand implements ICommand {
297297
} --json --disable-analytics`,
298298
{
299299
cwd: currentPath,
300-
}
300+
},
301301
)
302302
.then((res) => {
303303
const cleanupRes = JSON.parse(res) as IProjectCleanupResult;
@@ -311,7 +311,7 @@ export class CleanCommand implements ICommand {
311311
if (ok) {
312312
const cleanedSize = projects.get(currentPath);
313313
const cleanedSizeStr = color.grey(
314-
`- ${bytesToHumanReadable(cleanedSize)}`
314+
`- ${bytesToHumanReadable(cleanedSize)}`,
315315
);
316316
spinner.succeed(`Cleaned ${color.cyan(currentPath)} ${cleanedSizeStr}`);
317317
totalSizeCleaned += cleanedSize;
@@ -323,19 +323,19 @@ export class CleanCommand implements ICommand {
323323
spinner.stop();
324324
spinner.succeed(
325325
`Done! We've just freed up ${color.green(
326-
bytesToHumanReadable(totalSizeCleaned)
327-
)}! Woohoo! 🎉`
326+
bytesToHumanReadable(totalSizeCleaned),
327+
)}! Woohoo! 🎉`,
328328
);
329329

330330
if (this.$options.dryRun) {
331331
spinner.info(
332-
'Note: the "--dry-run" flag was used, so no files were actually deleted.'
332+
'Note: the "--dry-run" flag was used, so no files were actually deleted.',
333333
);
334334
}
335335
}
336336

337337
private async getNSProjectPathsInDirectory(
338-
dir = process.cwd()
338+
dir = process.cwd(),
339339
): Promise<string[]> {
340340
let nsDirs: string[] = [];
341341

@@ -346,20 +346,20 @@ export class CleanCommand implements ICommand {
346346
}
347347

348348
const dirents = await readdir(dir, { withFileTypes: true }).catch(
349-
(err) => {
349+
(err): any[] => {
350350
this.$logger.trace(
351351
'Failed to read directory "%s". Error is:',
352352
dir,
353-
err
353+
err,
354354
);
355355
return [];
356-
}
356+
},
357357
);
358358

359359
const hasNSConfig = dirents.some(
360360
(ent) =>
361361
ent.name.includes("nativescript.config.ts") ||
362-
ent.name.includes("nativescript.config.js")
362+
ent.name.includes("nativescript.config.js"),
363363
);
364364

365365
if (hasNSConfig) {
@@ -375,7 +375,7 @@ export class CleanCommand implements ICommand {
375375
if (dirent.isDirectory()) {
376376
return getFiles(res);
377377
}
378-
})
378+
}),
379379
);
380380
};
381381

lib/commands/generate.ts

+53-51
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
1-
import { run, ExecutionOptions } from "@nativescript/schematics-executor";
2-
import { IOptions } from "../declarations";
1+
// import { run, ExecutionOptions } from "@nativescript/schematics-executor";
2+
// import { IOptions } from "../declarations";
33
import { ICommand, ICommandParameter } from "../common/definitions/commands";
44
import { IErrors } from "../common/declarations";
55
import { injector } from "../common/yok";
66

77
export class GenerateCommand implements ICommand {
88
public allowedParameters: ICommandParameter[] = [];
9-
private executionOptions: ExecutionOptions;
9+
// private executionOptions: ExecutionOptions;
1010

1111
constructor(
1212
private $logger: ILogger,
13-
private $options: IOptions,
14-
private $errors: IErrors
13+
// private $options: IOptions,
14+
private $errors: IErrors,
1515
) {}
1616

1717
public async execute(_rawArgs: string[]): Promise<void> {
1818
try {
19-
await run(this.executionOptions);
19+
this.$logger.info(
20+
"If you have ideas for this command, please discuss at https://nativescript.org/discord",
21+
);
22+
// await run(this.executionOptions);
2023
} catch (error) {
2124
this.$errors.fail(error.message);
2225
}
@@ -30,68 +33,67 @@ export class GenerateCommand implements ICommand {
3033
}
3134

3235
private validateExecutionOptions() {
33-
if (!this.executionOptions.schematic) {
34-
this.$errors.failWithHelp(
35-
`The generate command requires a schematic name to be specified.`
36-
);
37-
}
36+
// if (!this.executionOptions.schematic) {
37+
// this.$errors.failWithHelp(
38+
// `The generate command requires a schematic name to be specified.`
39+
// );
40+
// }
3841
}
3942

4043
private setExecutionOptions(rawArgs: string[]) {
41-
const options = this.parseRawArgs(rawArgs);
42-
43-
this.executionOptions = {
44-
...options,
45-
logger: this.$logger,
46-
directory: process.cwd(),
47-
};
44+
// const options = this.parseRawArgs(rawArgs);
45+
// this.executionOptions = {
46+
// ...options,
47+
// logger: this.$logger,
48+
// directory: process.cwd(),
49+
// };
4850
}
4951

50-
private parseRawArgs(rawArgs: string[]) {
51-
const collection = this.$options.collection;
52-
const schematic = rawArgs.shift();
53-
const { options, args } = parseSchematicSettings(rawArgs);
52+
// private parseRawArgs(rawArgs: string[]) {
53+
// const collection = this.$options.collection;
54+
// const schematic = rawArgs.shift();
55+
// const { options, args } = parseSchematicSettings(rawArgs);
5456

55-
return {
56-
collection,
57-
schematic,
58-
schematicOptions: options,
59-
schematicArgs: args,
60-
};
61-
}
57+
// return {
58+
// collection,
59+
// schematic,
60+
// schematicOptions: options,
61+
// schematicArgs: args,
62+
// };
63+
// }
6264
}
6365

6466
/**
6567
* Converts an array of command line arguments to options for the executed schematic.
6668
* @param rawArgs The command line arguments. They should be in the format 'key=value' for strings or 'key' for booleans.
6769
*/
68-
function parseSchematicSettings(rawArgs: string[]) {
69-
const [optionStrings, args] = partition<string>(rawArgs, (item) =>
70-
item.includes("=")
71-
);
72-
const options = optionStrings
73-
.map((o) => o.split("=")) // split to key and value pairs
74-
.map(([key, ...value]) => [key, value.join("=")]) // concat the value arrays if there are multiple = signs
75-
.reduce((obj, [key, value]) => {
76-
return { ...obj, [key]: value };
77-
}, {});
70+
// function parseSchematicSettings(rawArgs: string[]) {
71+
// const [optionStrings, args] = partition<string>(rawArgs, (item) =>
72+
// item.includes("=")
73+
// );
74+
// const options = optionStrings
75+
// .map((o) => o.split("=")) // split to key and value pairs
76+
// .map(([key, ...value]) => [key, value.join("=")]) // concat the value arrays if there are multiple = signs
77+
// .reduce((obj, [key, value]) => {
78+
// return { ...obj, [key]: value };
79+
// }, {});
7880

79-
return { options, args };
80-
}
81+
// return { options, args };
82+
// }
8183
/**
8284
* Splits an array into two groups based on a predicate.
8385
* @param array The array to split.
8486
* @param predicate The condition to be used for splitting.
8587
*/
86-
function partition<T>(array: T[], predicate: (item: T) => boolean): T[][] {
87-
return array.reduce(
88-
([pass, fail], item) => {
89-
return predicate(item)
90-
? [[...pass, item], fail]
91-
: [pass, [...fail, item]];
92-
},
93-
[[], []]
94-
);
95-
}
88+
// function partition<T>(array: T[], predicate: (item: T) => boolean): T[][] {
89+
// return array.reduce(
90+
// ([pass, fail], item) => {
91+
// return predicate(item)
92+
// ? [[...pass, item], fail]
93+
// : [pass, [...fail, item]];
94+
// },
95+
// [[], []]
96+
// );
97+
// }
9698

9799
injector.registerCommand("generate", GenerateCommand);

0 commit comments

Comments
 (0)