@fluojs/cli 1.0.0-beta.2 → 1.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ko.md +5 -2
- package/README.md +5 -2
- package/dist/commands/inspect.d.ts.map +1 -1
- package/dist/commands/inspect.js +5 -1
- package/dist/commands/new.d.ts.map +1 -1
- package/dist/commands/new.js +4 -0
- package/dist/generators/controller.d.ts +7 -0
- package/dist/generators/controller.d.ts.map +1 -1
- package/dist/generators/controller.js +8 -0
- package/dist/generators/guard.d.ts +6 -0
- package/dist/generators/guard.d.ts.map +1 -1
- package/dist/generators/guard.js +7 -0
- package/dist/generators/interceptor.d.ts +6 -0
- package/dist/generators/interceptor.d.ts.map +1 -1
- package/dist/generators/interceptor.js +7 -0
- package/dist/generators/middleware.d.ts +6 -0
- package/dist/generators/middleware.d.ts.map +1 -1
- package/dist/generators/middleware.js +7 -0
- package/dist/generators/module.d.ts +22 -0
- package/dist/generators/module.d.ts.map +1 -1
- package/dist/generators/module.js +25 -0
- package/dist/generators/render.d.ts +7 -0
- package/dist/generators/render.d.ts.map +1 -1
- package/dist/generators/render.js +8 -0
- package/dist/generators/repository.d.ts +7 -0
- package/dist/generators/repository.d.ts.map +1 -1
- package/dist/generators/repository.js +8 -0
- package/dist/generators/request-dto.d.ts +6 -0
- package/dist/generators/request-dto.d.ts.map +1 -1
- package/dist/generators/request-dto.js +7 -0
- package/dist/generators/response-dto.d.ts +6 -0
- package/dist/generators/response-dto.d.ts.map +1 -1
- package/dist/generators/response-dto.js +7 -0
- package/dist/generators/service.d.ts +7 -0
- package/dist/generators/service.d.ts.map +1 -1
- package/dist/generators/service.js +8 -0
- package/dist/generators/utils.d.ts +18 -0
- package/dist/generators/utils.d.ts.map +1 -1
- package/dist/generators/utils.js +20 -0
- package/dist/help.d.ts +13 -0
- package/dist/help.d.ts.map +1 -1
- package/dist/help.js +15 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/new/package-spec-resolver.d.ts +7 -0
- package/dist/new/package-spec-resolver.d.ts.map +1 -1
- package/dist/new/package-spec-resolver.js +8 -0
- package/dist/new/prompt.d.ts.map +1 -1
- package/dist/new/prompt.js +5 -3
- package/dist/new/scaffold.d.ts.map +1 -1
- package/dist/new/scaffold.js +15 -14
- package/dist/prompt-cancel.d.ts +44 -0
- package/dist/prompt-cancel.d.ts.map +1 -0
- package/dist/prompt-cancel.js +49 -0
- package/dist/transforms/nestjs-migrate.d.ts +48 -0
- package/dist/transforms/nestjs-migrate.d.ts.map +1 -1
- package/dist/transforms/nestjs-migrate.js +62 -0
- package/dist/update-check.d.ts +32 -0
- package/dist/update-check.d.ts.map +1 -1
- package/dist/update-check.js +125 -6
- package/package.json +3 -3
|
@@ -366,6 +366,14 @@ function rewriteWorkspaceProtocolDependencies(manifest, packageVersions) {
|
|
|
366
366
|
}
|
|
367
367
|
}
|
|
368
368
|
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Resolve package specs.
|
|
372
|
+
*
|
|
373
|
+
* @param options The options.
|
|
374
|
+
* @param bootstrapPlan The bootstrap plan.
|
|
375
|
+
* @returns The resolve package specs result.
|
|
376
|
+
*/
|
|
369
377
|
export async function resolvePackageSpecs(options, bootstrapPlan) {
|
|
370
378
|
if (options.dependencySource !== 'local' || !options.repoRoot) {
|
|
371
379
|
return {};
|
package/dist/new/prompt.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/new/prompt.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/new/prompt.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,YAAY,C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AAO,EAAE,OAAO,CAAC,gBAAgB,CAAC,EAClC,GAAG,EAAE,MAAM,EACX,SAAS,CAAC,EAAE,MAAM,GACjB,gBAAgB,CAgBlB;AAED;;;;;;;;GAQG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC,EAClC,GAAG,EAAE,MAAM,EACX,SAAS,CAAC,EAAE,MAAM,EAClB,OAAO,GAAE,8BAAmC,GAC3C,OAAO,CAAC,gBAAgB,CAAC,CA0B3B"}
|
package/dist/new/prompt.js
CHANGED
|
@@ -3,6 +3,8 @@ import { dirname, join, resolve } from 'node:path';
|
|
|
3
3
|
import * as clack from '@clack/prompts';
|
|
4
4
|
import { resolveBootstrapSchema } from './resolver.js';
|
|
5
5
|
import { DOCUMENTED_MICROSERVICE_TRANSPORTS, getApplicationStarterProfiles } from './starter-profiles.js';
|
|
6
|
+
import { CliPromptCancelledError } from '../prompt-cancel.js';
|
|
7
|
+
|
|
6
8
|
/** Default package manager used when detection has no signal. */
|
|
7
9
|
export const DEFAULT_PACKAGE_MANAGER = 'pnpm';
|
|
8
10
|
const DEFAULT_INSTALL_DEPENDENCIES = true;
|
|
@@ -40,7 +42,7 @@ function createBootstrapPrompter() {
|
|
|
40
42
|
});
|
|
41
43
|
if (clack.isCancel(result)) {
|
|
42
44
|
clack.cancel('Operation cancelled.');
|
|
43
|
-
|
|
45
|
+
throw new CliPromptCancelledError();
|
|
44
46
|
}
|
|
45
47
|
return result;
|
|
46
48
|
},
|
|
@@ -55,7 +57,7 @@ function createBootstrapPrompter() {
|
|
|
55
57
|
});
|
|
56
58
|
if (clack.isCancel(result)) {
|
|
57
59
|
clack.cancel('Operation cancelled.');
|
|
58
|
-
|
|
60
|
+
throw new CliPromptCancelledError();
|
|
59
61
|
}
|
|
60
62
|
return result;
|
|
61
63
|
},
|
|
@@ -70,7 +72,7 @@ function createBootstrapPrompter() {
|
|
|
70
72
|
});
|
|
71
73
|
if (clack.isCancel(result)) {
|
|
72
74
|
clack.cancel('Operation cancelled.');
|
|
73
|
-
|
|
75
|
+
throw new CliPromptCancelledError();
|
|
74
76
|
}
|
|
75
77
|
return result;
|
|
76
78
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scaffold.d.ts","sourceRoot":"","sources":["../../src/new/scaffold.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,gBAAgB,EAAkB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"scaffold.d.ts","sourceRoot":"","sources":["../../src/new/scaffold.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,gBAAgB,EAAkB,MAAM,YAAY,CAAC;AAokEnE;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,gBAAgB,EACzB,aAAa,SAAkB,GAC9B,OAAO,CAAC,IAAI,CAAC,CA6Bf;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,6BAAuB,CAAC"}
|
package/dist/new/scaffold.js
CHANGED
|
@@ -27,20 +27,21 @@ const PUBLISHED_RUNTIME_DEPENDENCIES = {
|
|
|
27
27
|
nats: '^2.29.3'
|
|
28
28
|
};
|
|
29
29
|
const PUBLISHED_INTERNAL_DEPENDENCIES = {
|
|
30
|
-
'@fluojs/cli': '^1.0.0-beta.
|
|
31
|
-
'@fluojs/config': '^1.0.0-beta.
|
|
32
|
-
'@fluojs/core': '^1.0.0-beta.
|
|
33
|
-
'@fluojs/di': '^1.0.0-beta.
|
|
34
|
-
'@fluojs/http': '^1.0.0-beta.
|
|
35
|
-
'@fluojs/microservices': '^1.0.0-beta.
|
|
36
|
-
'@fluojs/platform-bun': '^1.0.0-beta.
|
|
37
|
-
'@fluojs/platform-cloudflare-workers': '^1.0.0-beta.
|
|
38
|
-
'@fluojs/platform-deno': '^1.0.0-beta.
|
|
39
|
-
'@fluojs/platform-express': '^1.0.0-beta.
|
|
40
|
-
'@fluojs/platform-fastify': '^1.0.0-beta.
|
|
41
|
-
'@fluojs/platform-nodejs': '^1.0.0-beta.
|
|
42
|
-
'@fluojs/runtime': '^1.0.0-beta.
|
|
43
|
-
'@fluojs/testing': '^1.0.0-beta.
|
|
30
|
+
'@fluojs/cli': '^1.0.0-beta.3',
|
|
31
|
+
'@fluojs/config': '^1.0.0-beta.5',
|
|
32
|
+
'@fluojs/core': '^1.0.0-beta.3',
|
|
33
|
+
'@fluojs/di': '^1.0.0-beta.6',
|
|
34
|
+
'@fluojs/http': '^1.0.0-beta.9',
|
|
35
|
+
'@fluojs/microservices': '^1.0.0-beta.3',
|
|
36
|
+
'@fluojs/platform-bun': '^1.0.0-beta.6',
|
|
37
|
+
'@fluojs/platform-cloudflare-workers': '^1.0.0-beta.2',
|
|
38
|
+
'@fluojs/platform-deno': '^1.0.0-beta.3',
|
|
39
|
+
'@fluojs/platform-express': '^1.0.0-beta.6',
|
|
40
|
+
'@fluojs/platform-fastify': '^1.0.0-beta.8',
|
|
41
|
+
'@fluojs/platform-nodejs': '^1.0.0-beta.4',
|
|
42
|
+
'@fluojs/runtime': '^1.0.0-beta.9',
|
|
43
|
+
'@fluojs/testing': '^1.0.0-beta.2',
|
|
44
|
+
'@fluojs/validation': '^1.0.0-beta.2'
|
|
44
45
|
};
|
|
45
46
|
function describeApplicationStarter(options) {
|
|
46
47
|
if (options.runtime === 'bun') {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable sentinel error for caller-owned prompt cancellation.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Programmatic prompt hooks passed to `runCli(...)` or `runNewCommand(...)`
|
|
6
|
+
* can throw this error to report a normal user cancellation without relying on
|
|
7
|
+
* CLI internals or terminating the host process.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { CliPromptCancelledError, runNewCommand } from '@fluojs/cli';
|
|
12
|
+
*
|
|
13
|
+
* const exitCode = await runNewCommand([], {
|
|
14
|
+
* interactive: true,
|
|
15
|
+
* prompt: {
|
|
16
|
+
* async text() {
|
|
17
|
+
* throw new CliPromptCancelledError();
|
|
18
|
+
* },
|
|
19
|
+
* async select(_message, _choices, defaultValue) {
|
|
20
|
+
* return defaultValue ?? 'pnpm';
|
|
21
|
+
* },
|
|
22
|
+
* async confirm(_message, defaultValue) {
|
|
23
|
+
* return defaultValue;
|
|
24
|
+
* },
|
|
25
|
+
* },
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare class CliPromptCancelledError extends Error {
|
|
30
|
+
/**
|
|
31
|
+
* Creates a prompt cancellation sentinel.
|
|
32
|
+
*
|
|
33
|
+
* @param message Optional cancellation message for diagnostics.
|
|
34
|
+
*/
|
|
35
|
+
constructor(message?: string);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Checks whether a thrown value represents a user-cancelled CLI prompt.
|
|
39
|
+
*
|
|
40
|
+
* @param error Value caught from a command execution path.
|
|
41
|
+
* @returns `true` when the value is a `CliPromptCancelledError`.
|
|
42
|
+
*/
|
|
43
|
+
export declare function isCliPromptCancelledError(error: unknown): error is CliPromptCancelledError;
|
|
44
|
+
//# sourceMappingURL=prompt-cancel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-cancel.d.ts","sourceRoot":"","sources":["../src/prompt-cancel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;IAChD;;;;OAIG;gBACS,OAAO,SAAyB;CAI7C;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,uBAAuB,CAE1F"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable sentinel error for caller-owned prompt cancellation.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Programmatic prompt hooks passed to `runCli(...)` or `runNewCommand(...)`
|
|
6
|
+
* can throw this error to report a normal user cancellation without relying on
|
|
7
|
+
* CLI internals or terminating the host process.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { CliPromptCancelledError, runNewCommand } from '@fluojs/cli';
|
|
12
|
+
*
|
|
13
|
+
* const exitCode = await runNewCommand([], {
|
|
14
|
+
* interactive: true,
|
|
15
|
+
* prompt: {
|
|
16
|
+
* async text() {
|
|
17
|
+
* throw new CliPromptCancelledError();
|
|
18
|
+
* },
|
|
19
|
+
* async select(_message, _choices, defaultValue) {
|
|
20
|
+
* return defaultValue ?? 'pnpm';
|
|
21
|
+
* },
|
|
22
|
+
* async confirm(_message, defaultValue) {
|
|
23
|
+
* return defaultValue;
|
|
24
|
+
* },
|
|
25
|
+
* },
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export class CliPromptCancelledError extends Error {
|
|
30
|
+
/**
|
|
31
|
+
* Creates a prompt cancellation sentinel.
|
|
32
|
+
*
|
|
33
|
+
* @param message Optional cancellation message for diagnostics.
|
|
34
|
+
*/
|
|
35
|
+
constructor(message = 'Operation cancelled.') {
|
|
36
|
+
super(message);
|
|
37
|
+
this.name = 'CliPromptCancelledError';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Checks whether a thrown value represents a user-cancelled CLI prompt.
|
|
43
|
+
*
|
|
44
|
+
* @param error Value caught from a command execution path.
|
|
45
|
+
* @returns `true` when the value is a `CliPromptCancelledError`.
|
|
46
|
+
*/
|
|
47
|
+
export function isCliPromptCancelledError(error) {
|
|
48
|
+
return error instanceof CliPromptCancelledError;
|
|
49
|
+
}
|
|
@@ -1,21 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provides the migration transforms value.
|
|
3
|
+
*/
|
|
1
4
|
export declare const MIGRATION_TRANSFORMS: readonly ["imports", "injectable", "scope", "bootstrap", "testing", "tsconfig"];
|
|
5
|
+
/**
|
|
6
|
+
* Defines the migration transform kind type.
|
|
7
|
+
*/
|
|
2
8
|
export type MigrationTransformKind = typeof MIGRATION_TRANSFORMS[number];
|
|
9
|
+
/**
|
|
10
|
+
* Provides the warning categories value.
|
|
11
|
+
*/
|
|
3
12
|
export declare const WARNING_CATEGORIES: readonly ["inject-token", "request-dto", "pipe-converter", "bootstrap-unsupported", "testing-unsupported", "import-unsupported", "injectable-options", "tsconfig-parse", "bootstrap-port"];
|
|
13
|
+
/**
|
|
14
|
+
* Defines the warning category type.
|
|
15
|
+
*/
|
|
4
16
|
export type WarningCategory = typeof WARNING_CATEGORIES[number];
|
|
17
|
+
/**
|
|
18
|
+
* Defines the migration warning type.
|
|
19
|
+
*/
|
|
5
20
|
export type MigrationWarning = {
|
|
6
21
|
category: WarningCategory;
|
|
7
22
|
filePath: string;
|
|
8
23
|
line: number;
|
|
9
24
|
message: string;
|
|
10
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* Get warning category label.
|
|
28
|
+
*
|
|
29
|
+
* @param category The category.
|
|
30
|
+
* @returns The get warning category label result.
|
|
31
|
+
*/
|
|
11
32
|
export declare function getWarningCategoryLabel(category: WarningCategory): string;
|
|
33
|
+
/**
|
|
34
|
+
* Group warnings by category.
|
|
35
|
+
*
|
|
36
|
+
* @param warnings The warnings.
|
|
37
|
+
* @returns The group warnings by category result.
|
|
38
|
+
*/
|
|
12
39
|
export declare function groupWarningsByCategory(warnings: MigrationWarning[]): Map<WarningCategory, MigrationWarning[]>;
|
|
40
|
+
/**
|
|
41
|
+
* Defines the file migration result type.
|
|
42
|
+
*/
|
|
13
43
|
export type FileMigrationResult = {
|
|
14
44
|
appliedTransforms: MigrationTransformKind[];
|
|
15
45
|
changed: boolean;
|
|
16
46
|
filePath: string;
|
|
17
47
|
warnings: MigrationWarning[];
|
|
18
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* Defines the migration report type.
|
|
51
|
+
*/
|
|
19
52
|
export type MigrationReport = {
|
|
20
53
|
apply: boolean;
|
|
21
54
|
changedFiles: number;
|
|
@@ -23,11 +56,26 @@ export type MigrationReport = {
|
|
|
23
56
|
warningCount: number;
|
|
24
57
|
fileResults: FileMigrationResult[];
|
|
25
58
|
};
|
|
59
|
+
/**
|
|
60
|
+
* Defines the run nest js migration options type.
|
|
61
|
+
*/
|
|
26
62
|
export type RunNestJsMigrationOptions = {
|
|
27
63
|
apply: boolean;
|
|
28
64
|
enabledTransforms: ReadonlySet<MigrationTransformKind>;
|
|
29
65
|
targetPath: string;
|
|
30
66
|
};
|
|
67
|
+
/**
|
|
68
|
+
* Run nest js migration.
|
|
69
|
+
*
|
|
70
|
+
* @param options The options.
|
|
71
|
+
* @returns The run nest js migration result.
|
|
72
|
+
*/
|
|
31
73
|
export declare function runNestJsMigration(options: RunNestJsMigrationOptions): MigrationReport;
|
|
74
|
+
/**
|
|
75
|
+
* Render transform list.
|
|
76
|
+
*
|
|
77
|
+
* @param kinds The kinds.
|
|
78
|
+
* @returns The render transform list result.
|
|
79
|
+
*/
|
|
32
80
|
export declare function renderTransformList(kinds: readonly MigrationTransformKind[]): string;
|
|
33
81
|
//# sourceMappingURL=nestjs-migrate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nestjs-migrate.d.ts","sourceRoot":"","sources":["../../src/transforms/nestjs-migrate.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,oBAAoB,iFAAkF,CAAC;AAEpH,MAAM,MAAM,sBAAsB,GAAG,OAAO,oBAAoB,CAAC,MAAM,CAAC,CAAC;AAOzE,eAAO,MAAM,kBAAkB,4LAUrB,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAEhE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,eAAe,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,IA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F"}
|
|
@@ -1,8 +1,29 @@
|
|
|
1
1
|
import { existsSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { basename, extname, posix, resolve } from 'node:path';
|
|
3
3
|
import ts from 'typescript';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Provides the migration transforms value.
|
|
7
|
+
*/
|
|
4
8
|
export const MIGRATION_TRANSFORMS = ['imports', 'injectable', 'scope', 'bootstrap', 'testing', 'tsconfig'];
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Defines the migration transform kind type.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Provides the warning categories value.
|
|
16
|
+
*/
|
|
5
17
|
export const WARNING_CATEGORIES = ['inject-token', 'request-dto', 'pipe-converter', 'bootstrap-unsupported', 'testing-unsupported', 'import-unsupported', 'injectable-options', 'tsconfig-parse', 'bootstrap-port'];
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Defines the warning category type.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Defines the migration warning type.
|
|
25
|
+
*/
|
|
26
|
+
|
|
6
27
|
const WARNING_CATEGORY_LABEL = {
|
|
7
28
|
'inject-token': 'DI token migration (@Inject)',
|
|
8
29
|
'request-dto': 'Request DTO migration (handler parameter decorators)',
|
|
@@ -14,9 +35,23 @@ const WARNING_CATEGORY_LABEL = {
|
|
|
14
35
|
'tsconfig-parse': 'tsconfig parse failure',
|
|
15
36
|
'bootstrap-port': 'Bootstrap port folding issue'
|
|
16
37
|
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Get warning category label.
|
|
41
|
+
*
|
|
42
|
+
* @param category The category.
|
|
43
|
+
* @returns The get warning category label result.
|
|
44
|
+
*/
|
|
17
45
|
export function getWarningCategoryLabel(category) {
|
|
18
46
|
return WARNING_CATEGORY_LABEL[category];
|
|
19
47
|
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Group warnings by category.
|
|
51
|
+
*
|
|
52
|
+
* @param warnings The warnings.
|
|
53
|
+
* @returns The group warnings by category result.
|
|
54
|
+
*/
|
|
20
55
|
export function groupWarningsByCategory(warnings) {
|
|
21
56
|
const groups = new Map();
|
|
22
57
|
for (const warning of warnings) {
|
|
@@ -26,6 +61,19 @@ export function groupWarningsByCategory(warnings) {
|
|
|
26
61
|
}
|
|
27
62
|
return groups;
|
|
28
63
|
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Defines the file migration result type.
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Defines the migration report type.
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Defines the run nest js migration options type.
|
|
75
|
+
*/
|
|
76
|
+
|
|
29
77
|
const printer = ts.createPrinter({
|
|
30
78
|
newLine: ts.NewLineKind.LineFeed
|
|
31
79
|
});
|
|
@@ -841,6 +889,13 @@ function runTypeScriptTransforms(source, filePath, enabledTransforms) {
|
|
|
841
889
|
warnings
|
|
842
890
|
};
|
|
843
891
|
}
|
|
892
|
+
|
|
893
|
+
/**
|
|
894
|
+
* Run nest js migration.
|
|
895
|
+
*
|
|
896
|
+
* @param options The options.
|
|
897
|
+
* @returns The run nest js migration result.
|
|
898
|
+
*/
|
|
844
899
|
export function runNestJsMigration(options) {
|
|
845
900
|
const resolvedTargetPath = resolve(options.targetPath);
|
|
846
901
|
if (!existsSync(resolvedTargetPath)) {
|
|
@@ -886,6 +941,13 @@ export function runNestJsMigration(options) {
|
|
|
886
941
|
fileResults
|
|
887
942
|
};
|
|
888
943
|
}
|
|
944
|
+
|
|
945
|
+
/**
|
|
946
|
+
* Render transform list.
|
|
947
|
+
*
|
|
948
|
+
* @param kinds The kinds.
|
|
949
|
+
* @returns The render transform list result.
|
|
950
|
+
*/
|
|
889
951
|
export function renderTransformList(kinds) {
|
|
890
952
|
return kinds.map(kind => `${kind} (${TRANSFORM_KIND_LABEL[kind]})`).join(', ');
|
|
891
953
|
}
|
package/dist/update-check.d.ts
CHANGED
|
@@ -5,24 +5,41 @@ type CliStream = {
|
|
|
5
5
|
type CliReadableStream = {
|
|
6
6
|
isTTY?: boolean;
|
|
7
7
|
};
|
|
8
|
+
/**
|
|
9
|
+
* Defines the cli update check result type.
|
|
10
|
+
*/
|
|
8
11
|
export type CliUpdateCheckResult = {
|
|
9
12
|
action: 'continue';
|
|
10
13
|
} | {
|
|
11
14
|
action: 'reran';
|
|
12
15
|
exitCode: number;
|
|
13
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* Defines the update install command type.
|
|
19
|
+
*/
|
|
14
20
|
export type UpdateInstallCommand = {
|
|
15
21
|
args: string[];
|
|
16
22
|
command: string;
|
|
17
23
|
display: string;
|
|
18
24
|
};
|
|
25
|
+
/** Package manager that can install the CLI globally. */
|
|
26
|
+
export type UpdatePackageManager = 'bun' | 'npm' | 'pnpm' | 'yarn';
|
|
27
|
+
/**
|
|
28
|
+
* Defines the update command runtime type.
|
|
29
|
+
*/
|
|
19
30
|
export type UpdateCommandRuntime = {
|
|
20
31
|
env: NodeJS.ProcessEnv;
|
|
21
32
|
stderr: CliStream;
|
|
22
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* Defines the update prompter type.
|
|
36
|
+
*/
|
|
23
37
|
export type UpdatePrompter = {
|
|
24
38
|
confirm(message: string, defaultValue: boolean): Promise<boolean>;
|
|
25
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* Describes the cli update check runtime options contract.
|
|
42
|
+
*/
|
|
26
43
|
export interface CliUpdateCheckRuntimeOptions {
|
|
27
44
|
cacheFile?: string;
|
|
28
45
|
cacheTtlMs?: number;
|
|
@@ -34,6 +51,8 @@ export interface CliUpdateCheckRuntimeOptions {
|
|
|
34
51
|
interactive?: boolean;
|
|
35
52
|
now?: () => Date;
|
|
36
53
|
packageName?: string;
|
|
54
|
+
packageManager?: UpdatePackageManager;
|
|
55
|
+
packageRoot?: string;
|
|
37
56
|
prompt?: UpdatePrompter;
|
|
38
57
|
rerunCli?: (argv: string[], runtime: UpdateCommandRuntime) => Promise<number>;
|
|
39
58
|
skip?: boolean;
|
|
@@ -41,10 +60,23 @@ export interface CliUpdateCheckRuntimeOptions {
|
|
|
41
60
|
stdin?: CliReadableStream;
|
|
42
61
|
stdout?: CliStream;
|
|
43
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Remove update check flags.
|
|
65
|
+
*
|
|
66
|
+
* @param argv The argv.
|
|
67
|
+
* @returns The remove update check flags result.
|
|
68
|
+
*/
|
|
44
69
|
export declare function removeUpdateCheckFlags(argv: string[]): {
|
|
45
70
|
argv: string[];
|
|
46
71
|
skipUpdateCheck: boolean;
|
|
47
72
|
};
|
|
73
|
+
/**
|
|
74
|
+
* Run cli update check.
|
|
75
|
+
*
|
|
76
|
+
* @param argv The argv.
|
|
77
|
+
* @param options The options.
|
|
78
|
+
* @returns The run cli update check result.
|
|
79
|
+
*/
|
|
48
80
|
export declare function runCliUpdateCheck(argv: string[], options?: CliUpdateCheckRuntimeOptions): Promise<CliUpdateCheckResult>;
|
|
49
81
|
export {};
|
|
50
82
|
//# sourceMappingURL=update-check.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-check.d.ts","sourceRoot":"","sources":["../src/update-check.ts"],"names":[],"mappings":"AAOA,KAAK,SAAS,GAAG;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;CACjC,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAcF,MAAM,MAAM,oBAAoB,GAC5B;IACE,MAAM,EAAE,UAAU,CAAC;CACpB,GACD;IACE,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEN,MAAM,MAAM,oBAAo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E,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC1E,cAAc,CAAC,EAAE,CAAC,cAAc,EAAE,oBAAoB,EAAE,OAAO,EAAE,oBAAoB,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1G,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,oBAAoB,CAAC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,oBAAoB,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAC9E,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,MAAM,CAAC,EAAE,SAAS,CAAC;CACpB;AAscD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG;IAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,eAAe,EAAE,OAAO,CAAA;CAAE,CAcnG;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,4BAAiC,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAkEjI"}
|
package/dist/update-check.js
CHANGED
|
@@ -1,13 +1,37 @@
|
|
|
1
1
|
import { spawnSync } from 'node:child_process';
|
|
2
2
|
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
3
3
|
import { homedir } from 'node:os';
|
|
4
|
-
import { dirname, join } from 'node:path';
|
|
4
|
+
import { basename, dirname, join, sep } from 'node:path';
|
|
5
5
|
import { createInterface } from 'node:readline/promises';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Defines the cli update check result type.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Defines the update install command type.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/** Package manager that can install the CLI globally. */
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Defines the update command runtime type.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Defines the update prompter type.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Describes the cli update check runtime options contract.
|
|
28
|
+
*/
|
|
29
|
+
|
|
7
30
|
const DEFAULT_CACHE_TTL_MS = 24 * 60 * 60 * 1000;
|
|
8
31
|
const DEFAULT_PACKAGE_NAME = '@fluojs/cli';
|
|
9
32
|
const DEFAULT_REGISTRY_TIMEOUT_MS = 5_000;
|
|
10
33
|
const UPDATE_CHECK_FLAGS = new Set(['--no-update-check', '--no-update-notifier']);
|
|
34
|
+
const UPDATE_PACKAGE_MANAGERS = new Set(['bun', 'npm', 'pnpm', 'yarn']);
|
|
11
35
|
function isRecord(value) {
|
|
12
36
|
return typeof value === 'object' && value !== null;
|
|
13
37
|
}
|
|
@@ -213,12 +237,90 @@ async function readOwnPackageVersion() {
|
|
|
213
237
|
return undefined;
|
|
214
238
|
}
|
|
215
239
|
}
|
|
216
|
-
function
|
|
240
|
+
function normalizePathForDetection(path) {
|
|
241
|
+
return (path ?? '').replaceAll('\\', '/').toLowerCase();
|
|
242
|
+
}
|
|
243
|
+
function parsePackageManagerName(value) {
|
|
244
|
+
if (!value) {
|
|
245
|
+
return undefined;
|
|
246
|
+
}
|
|
247
|
+
const normalized = value.trim().toLowerCase();
|
|
248
|
+
if (UPDATE_PACKAGE_MANAGERS.has(normalized)) {
|
|
249
|
+
return normalized;
|
|
250
|
+
}
|
|
251
|
+
return undefined;
|
|
252
|
+
}
|
|
253
|
+
function parsePackageManagerFromUserAgent(userAgent) {
|
|
254
|
+
const name = userAgent?.split(' ')[0]?.split('/')[0];
|
|
255
|
+
return parsePackageManagerName(name);
|
|
256
|
+
}
|
|
257
|
+
function parsePackageManagerFromExecPath(execPath) {
|
|
258
|
+
const executableName = basename(execPath ?? '', '.cmd').toLowerCase();
|
|
259
|
+
const packageManager = parsePackageManagerName(executableName.replace(/\.(?:cjs|mjs|js)$/, ''));
|
|
260
|
+
if (packageManager) {
|
|
261
|
+
return packageManager;
|
|
262
|
+
}
|
|
263
|
+
const normalizedPath = normalizePathForDetection(execPath);
|
|
264
|
+
if (normalizedPath.includes('/pnpm/')) {
|
|
265
|
+
return 'pnpm';
|
|
266
|
+
}
|
|
267
|
+
if (normalizedPath.includes('/yarn/')) {
|
|
268
|
+
return 'yarn';
|
|
269
|
+
}
|
|
270
|
+
if (normalizedPath.includes('/bun/')) {
|
|
271
|
+
return 'bun';
|
|
272
|
+
}
|
|
273
|
+
if (normalizedPath.includes('/npm/')) {
|
|
274
|
+
return 'npm';
|
|
275
|
+
}
|
|
276
|
+
return undefined;
|
|
277
|
+
}
|
|
278
|
+
function parsePackageManagerFromPackageRoot(packageRoot) {
|
|
279
|
+
const normalizedPath = normalizePathForDetection(`${sep}${packageRoot}${sep}`);
|
|
280
|
+
if (normalizedPath.includes('/.pnpm/') || normalizedPath.includes('/pnpm/global/')) {
|
|
281
|
+
return 'pnpm';
|
|
282
|
+
}
|
|
283
|
+
if (normalizedPath.includes('/.bun/install/global/') || normalizedPath.includes('/bun/install/global/')) {
|
|
284
|
+
return 'bun';
|
|
285
|
+
}
|
|
286
|
+
if (normalizedPath.includes('/.config/yarn/global/') || normalizedPath.includes('/yarn/global/')) {
|
|
287
|
+
return 'yarn';
|
|
288
|
+
}
|
|
289
|
+
if (normalizedPath.includes('/node_modules/')) {
|
|
290
|
+
return 'npm';
|
|
291
|
+
}
|
|
292
|
+
return undefined;
|
|
293
|
+
}
|
|
294
|
+
function resolveUpdatePackageManager(env, packageRoot) {
|
|
295
|
+
return parsePackageManagerName(env.FLUO_UPDATE_PACKAGE_MANAGER) ?? parsePackageManagerFromPackageRoot(packageRoot) ?? parsePackageManagerFromUserAgent(env.npm_config_user_agent) ?? parsePackageManagerFromExecPath(env.npm_execpath) ?? 'npm';
|
|
296
|
+
}
|
|
297
|
+
function resolveInstallCommand(packageName, latestVersion, packageManager) {
|
|
217
298
|
const packageSpecifier = `${packageName}@${latestVersion}`;
|
|
299
|
+
if (packageManager === 'bun') {
|
|
300
|
+
return {
|
|
301
|
+
args: ['add', '-g', packageSpecifier],
|
|
302
|
+
command: 'bun',
|
|
303
|
+
display: `bun add -g ${packageSpecifier}`
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
if (packageManager === 'pnpm') {
|
|
307
|
+
return {
|
|
308
|
+
args: ['add', '-g', packageSpecifier],
|
|
309
|
+
command: 'pnpm',
|
|
310
|
+
display: `pnpm add -g ${packageSpecifier}`
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
if (packageManager === 'yarn') {
|
|
314
|
+
return {
|
|
315
|
+
args: ['global', 'add', packageSpecifier],
|
|
316
|
+
command: 'yarn',
|
|
317
|
+
display: `yarn global add ${packageSpecifier}`
|
|
318
|
+
};
|
|
319
|
+
}
|
|
218
320
|
return {
|
|
219
|
-
args: ['
|
|
220
|
-
command: '
|
|
221
|
-
display: `
|
|
321
|
+
args: ['install', '-g', packageSpecifier],
|
|
322
|
+
command: 'npm',
|
|
323
|
+
display: `npm install -g ${packageSpecifier}`
|
|
222
324
|
};
|
|
223
325
|
}
|
|
224
326
|
async function defaultPromptConfirm(message, defaultValue) {
|
|
@@ -272,6 +374,13 @@ function shouldRunInteractiveUpdateCheck(options, env) {
|
|
|
272
374
|
}
|
|
273
375
|
return Boolean(options.stdin?.isTTY ?? process.stdin.isTTY) && Boolean(options.stdout?.isTTY ?? process.stdout.isTTY);
|
|
274
376
|
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Remove update check flags.
|
|
380
|
+
*
|
|
381
|
+
* @param argv The argv.
|
|
382
|
+
* @returns The remove update check flags result.
|
|
383
|
+
*/
|
|
275
384
|
export function removeUpdateCheckFlags(argv) {
|
|
276
385
|
const filteredArgv = [];
|
|
277
386
|
let skipUpdateCheck = false;
|
|
@@ -287,6 +396,14 @@ export function removeUpdateCheckFlags(argv) {
|
|
|
287
396
|
skipUpdateCheck
|
|
288
397
|
};
|
|
289
398
|
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Run cli update check.
|
|
402
|
+
*
|
|
403
|
+
* @param argv The argv.
|
|
404
|
+
* @param options The options.
|
|
405
|
+
* @returns The run cli update check result.
|
|
406
|
+
*/
|
|
290
407
|
export async function runCliUpdateCheck(argv, options = {}) {
|
|
291
408
|
const env = options.env ?? {};
|
|
292
409
|
const stderr = options.stderr ?? process.stderr;
|
|
@@ -306,6 +423,7 @@ export async function runCliUpdateCheck(argv, options = {}) {
|
|
|
306
423
|
const cacheFile = options.cacheFile ?? resolveCacheFile(env);
|
|
307
424
|
const cacheTtlMs = options.cacheTtlMs ?? DEFAULT_CACHE_TTL_MS;
|
|
308
425
|
const currentVersion = options.currentVersion ?? (await readOwnPackageVersion());
|
|
426
|
+
const packageRoot = options.packageRoot ?? dirname(fileURLToPath(new URL('../package.json', import.meta.url)));
|
|
309
427
|
if (!currentVersion) {
|
|
310
428
|
return {
|
|
311
429
|
action: 'continue'
|
|
@@ -328,7 +446,8 @@ export async function runCliUpdateCheck(argv, options = {}) {
|
|
|
328
446
|
action: 'continue'
|
|
329
447
|
};
|
|
330
448
|
}
|
|
331
|
-
const
|
|
449
|
+
const packageManager = options.packageManager ?? resolveUpdatePackageManager(env, packageRoot);
|
|
450
|
+
const installCommand = resolveInstallCommand(packageName, latestVersion, packageManager);
|
|
332
451
|
stderr.write(`Installing ${packageName}@${latestVersion} with \`${installCommand.display}\`...\n`);
|
|
333
452
|
const commandRuntime = {
|
|
334
453
|
env,
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"migration",
|
|
10
10
|
"diagnostics"
|
|
11
11
|
],
|
|
12
|
-
"version": "1.0.0-beta.
|
|
12
|
+
"version": "1.0.0-beta.4",
|
|
13
13
|
"private": false,
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"repository": {
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"ejs": "^3.1.10",
|
|
45
45
|
"tsx": "^4.20.4",
|
|
46
46
|
"typescript": "^6.0.2",
|
|
47
|
-
"@fluojs/runtime": "^1.0.0-beta.
|
|
47
|
+
"@fluojs/runtime": "^1.0.0-beta.9"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@fluojs/studio": "^1.0.0-beta.
|
|
50
|
+
"@fluojs/studio": "^1.0.0-beta.3"
|
|
51
51
|
},
|
|
52
52
|
"peerDependenciesMeta": {
|
|
53
53
|
"@fluojs/studio": {
|