@vc-shell/migrate 2.0.0-alpha.12
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.md +359 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +45 -0
- package/dist/cli.js.map +1 -0
- package/dist/runner.d.ts +8 -0
- package/dist/runner.js +154 -0
- package/dist/runner.js.map +1 -0
- package/dist/transforms/banner-variants.d.ts +4 -0
- package/dist/transforms/banner-variants.js +21 -0
- package/dist/transforms/banner-variants.js.map +1 -0
- package/dist/transforms/blade-props-simplification.d.ts +4 -0
- package/dist/transforms/blade-props-simplification.js +315 -0
- package/dist/transforms/blade-props-simplification.js.map +1 -0
- package/dist/transforms/composable-return-types.d.ts +4 -0
- package/dist/transforms/composable-return-types.js +50 -0
- package/dist/transforms/composable-return-types.js.map +1 -0
- package/dist/transforms/define-app-module.d.ts +4 -0
- package/dist/transforms/define-app-module.js +73 -0
- package/dist/transforms/define-app-module.js.map +1 -0
- package/dist/transforms/icon-audit.d.ts +4 -0
- package/dist/transforms/icon-audit.js +38 -0
- package/dist/transforms/icon-audit.js.map +1 -0
- package/dist/transforms/icon-container-prop.d.ts +4 -0
- package/dist/transforms/icon-container-prop.js +14 -0
- package/dist/transforms/icon-container-prop.js.map +1 -0
- package/dist/transforms/menu-group-config.d.ts +4 -0
- package/dist/transforms/menu-group-config.js +22 -0
- package/dist/transforms/menu-group-config.js.map +1 -0
- package/dist/transforms/notification-migration.d.ts +4 -0
- package/dist/transforms/notification-migration.js +31 -0
- package/dist/transforms/notification-migration.js.map +1 -0
- package/dist/transforms/registry.d.ts +3 -0
- package/dist/transforms/registry.js +129 -0
- package/dist/transforms/registry.js.map +1 -0
- package/dist/transforms/remove-deprecated-aliases.d.ts +4 -0
- package/dist/transforms/remove-deprecated-aliases.js +36 -0
- package/dist/transforms/remove-deprecated-aliases.js.map +1 -0
- package/dist/transforms/rewrite-imports.d.ts +4 -0
- package/dist/transforms/rewrite-imports.js +62 -0
- package/dist/transforms/rewrite-imports.js.map +1 -0
- package/dist/transforms/scss-safe-use.d.ts +4 -0
- package/dist/transforms/scss-safe-use.js +50 -0
- package/dist/transforms/scss-safe-use.js.map +1 -0
- package/dist/transforms/shims-to-globals.d.ts +4 -0
- package/dist/transforms/shims-to-globals.js +64 -0
- package/dist/transforms/shims-to-globals.js.map +1 -0
- package/dist/transforms/switch-tooltip-prop.d.ts +4 -0
- package/dist/transforms/switch-tooltip-prop.js +12 -0
- package/dist/transforms/switch-tooltip-prop.js.map +1 -0
- package/dist/transforms/types.d.ts +30 -0
- package/dist/transforms/types.js +2 -0
- package/dist/transforms/types.js.map +1 -0
- package/dist/transforms/use-blade-migration.d.ts +4 -0
- package/dist/transforms/use-blade-migration.js +50 -0
- package/dist/transforms/use-blade-migration.js.map +1 -0
- package/dist/transforms/widgets-migration.d.ts +4 -0
- package/dist/transforms/widgets-migration.js +38 -0
- package/dist/transforms/widgets-migration.js.map +1 -0
- package/dist/utils/import-rewriter.d.ts +3 -0
- package/dist/utils/import-rewriter.js +22 -0
- package/dist/utils/import-rewriter.js.map +1 -0
- package/dist/utils/template-transform.d.ts +13 -0
- package/dist/utils/template-transform.js +37 -0
- package/dist/utils/template-transform.js.map +1 -0
- package/dist/utils/test-helpers.d.ts +32 -0
- package/dist/utils/test-helpers.js +49 -0
- package/dist/utils/test-helpers.js.map +1 -0
- package/dist/utils/vue-sfc-wrapper.d.ts +24 -0
- package/dist/utils/vue-sfc-wrapper.js +61 -0
- package/dist/utils/vue-sfc-wrapper.js.map +1 -0
- package/dist/version-detector.d.ts +1 -0
- package/dist/version-detector.js +32 -0
- package/dist/version-detector.js.map +1 -0
- package/package.json +33 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* String-based template attribute removal utility.
|
|
3
|
+
* Removes specific attributes from Vue template tags without full AST parsing.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Remove a list of attribute patterns from a specific tag in a template string.
|
|
7
|
+
* Each pattern is matched as a regex against attributes on the given tag.
|
|
8
|
+
*/
|
|
9
|
+
export function removeAttributesFromTag(template, tagName, attributePatterns) {
|
|
10
|
+
// Find the opening tag (handles multi-line)
|
|
11
|
+
const tagRegex = new RegExp(`(<${tagName}\\b)([^>]*?)(\\s*/?>)`, "gs");
|
|
12
|
+
return template.replace(tagRegex, (match, open, attrs, close) => {
|
|
13
|
+
let cleaned = attrs;
|
|
14
|
+
for (const pattern of attributePatterns) {
|
|
15
|
+
cleaned = cleaned.replace(pattern, "");
|
|
16
|
+
}
|
|
17
|
+
// Collapse multiple spaces/newlines into single space within attributes
|
|
18
|
+
cleaned = cleaned.replace(/\s{2,}/g, " ").trim();
|
|
19
|
+
if (cleaned)
|
|
20
|
+
cleaned = " " + cleaned;
|
|
21
|
+
return `${open}${cleaned}${close}`;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Remove blade boilerplate attributes from <VcBlade> in a template string.
|
|
26
|
+
*/
|
|
27
|
+
export function removeBladeBoilerplateFromTemplate(template) {
|
|
28
|
+
const patterns = [
|
|
29
|
+
/:expanded="expanded"/g,
|
|
30
|
+
/:closable="closable"/g,
|
|
31
|
+
/@close="\$emit\('close:blade'\)"/g,
|
|
32
|
+
/@expand="\$emit\('expand:blade'\)"/g,
|
|
33
|
+
/@collapse="\$emit\('collapse:blade'\)"/g,
|
|
34
|
+
];
|
|
35
|
+
return removeAttributesFromTag(template, "VcBlade", patterns);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=template-transform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-transform.js","sourceRoot":"","sources":["../../src/utils/template-transform.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CACrC,QAAgB,EAChB,OAAe,EACf,iBAA2B;IAE3B,4CAA4C;IAC5C,MAAM,QAAQ,GAAG,IAAI,MAAM,CACzB,KAAK,OAAO,uBAAuB,EACnC,IAAI,CACL,CAAC;IAEF,OAAO,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QAC9D,IAAI,OAAO,GAAG,KAAe,CAAC;QAC9B,KAAK,MAAM,OAAO,IAAI,iBAAiB,EAAE,CAAC;YACxC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QACzC,CAAC;QACD,wEAAwE;QACxE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;QACjD,IAAI,OAAO;YAAE,OAAO,GAAG,GAAG,GAAG,OAAO,CAAC;QACrC,OAAO,GAAG,IAAI,GAAG,OAAO,GAAG,KAAK,EAAE,CAAC;IACrC,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kCAAkC,CAAC,QAAgB;IACjE,MAAM,QAAQ,GAAG;QACf,uBAAuB;QACvB,uBAAuB;QACvB,mCAAmC;QACnC,qCAAqC;QACrC,yCAAyC;KAC1C,CAAC;IAEF,OAAO,uBAAuB,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Transform } from "../transforms/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Apply a jscodeshift transform to source code and return the result.
|
|
4
|
+
*/
|
|
5
|
+
export declare function applyTransform(transform: Transform, input: {
|
|
6
|
+
path: string;
|
|
7
|
+
source: string;
|
|
8
|
+
}, options?: Record<string, unknown>): string | null;
|
|
9
|
+
/**
|
|
10
|
+
* Apply a transform and also capture api.report() messages.
|
|
11
|
+
*/
|
|
12
|
+
export declare function applyTransformWithReports(transform: Transform, input: {
|
|
13
|
+
path: string;
|
|
14
|
+
source: string;
|
|
15
|
+
}, options?: Record<string, unknown>): {
|
|
16
|
+
result: string | null;
|
|
17
|
+
reports: string[];
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Run a fixture-based test: read input file, apply transform, compare with output file.
|
|
21
|
+
* If no output file exists, expects transform to return null (no changes).
|
|
22
|
+
* @param ext - file extension, default "ts". Use "vue" for SFC fixtures.
|
|
23
|
+
*/
|
|
24
|
+
export declare function defineFixtureTest(transform: Transform, fixturesDir: string, fixtureName: string, ext?: string): {
|
|
25
|
+
result: string | null;
|
|
26
|
+
expected: null;
|
|
27
|
+
match: boolean;
|
|
28
|
+
} | {
|
|
29
|
+
result: string | null;
|
|
30
|
+
expected: string;
|
|
31
|
+
match: boolean;
|
|
32
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { readFileSync, existsSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import jscodeshift from "jscodeshift";
|
|
4
|
+
/**
|
|
5
|
+
* Apply a jscodeshift transform to source code and return the result.
|
|
6
|
+
*/
|
|
7
|
+
export function applyTransform(transform, input, options = {}) {
|
|
8
|
+
const j = jscodeshift.withParser("tsx");
|
|
9
|
+
const api = {
|
|
10
|
+
jscodeshift: j,
|
|
11
|
+
j,
|
|
12
|
+
stats: () => { },
|
|
13
|
+
report: () => { },
|
|
14
|
+
};
|
|
15
|
+
return transform({ path: input.path, source: input.source }, api, { ...options });
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Apply a transform and also capture api.report() messages.
|
|
19
|
+
*/
|
|
20
|
+
export function applyTransformWithReports(transform, input, options = {}) {
|
|
21
|
+
const reports = [];
|
|
22
|
+
const j = jscodeshift.withParser("tsx");
|
|
23
|
+
const api = {
|
|
24
|
+
jscodeshift: j,
|
|
25
|
+
j,
|
|
26
|
+
stats: () => { },
|
|
27
|
+
report: (msg) => reports.push(msg),
|
|
28
|
+
};
|
|
29
|
+
const result = transform({ path: input.path, source: input.source }, api, { ...options });
|
|
30
|
+
return { result, reports };
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Run a fixture-based test: read input file, apply transform, compare with output file.
|
|
34
|
+
* If no output file exists, expects transform to return null (no changes).
|
|
35
|
+
* @param ext - file extension, default "ts". Use "vue" for SFC fixtures.
|
|
36
|
+
*/
|
|
37
|
+
export function defineFixtureTest(transform, fixturesDir, fixtureName, ext = "ts") {
|
|
38
|
+
const inputPath = join(fixturesDir, `${fixtureName}.input.${ext}`);
|
|
39
|
+
const outputPath = join(fixturesDir, `${fixtureName}.output.${ext}`);
|
|
40
|
+
const input = readFileSync(inputPath, "utf8");
|
|
41
|
+
const hasOutput = existsSync(outputPath);
|
|
42
|
+
const expected = hasOutput ? readFileSync(outputPath, "utf8") : null;
|
|
43
|
+
const result = applyTransform(transform, { path: inputPath, source: input });
|
|
44
|
+
if (expected === null) {
|
|
45
|
+
return { result, expected: null, match: result === null };
|
|
46
|
+
}
|
|
47
|
+
return { result, expected, match: result === expected };
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=test-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-helpers.js","sourceRoot":"","sources":["../../src/utils/test-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,WAAW,MAAM,aAAa,CAAC;AAGtC;;GAEG;AACH,MAAM,UAAU,cAAc,CAC5B,SAAoB,EACpB,KAAuC,EACvC,UAAmC,EAAE;IAErC,MAAM,CAAC,GAAG,WAAW,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,GAAG,GAAG;QACV,WAAW,EAAE,CAAC;QACd,CAAC;QACD,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;QACf,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC;KACjB,CAAC;IACF,OAAO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,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAErE,MAAM,MAAM,GAAG,cAAc,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;IAE7E,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtB,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,EAAE,CAAC;IAC5D,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,KAAK,QAAQ,EAAE,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Transform } from "../transforms/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Wraps a script-only jscodeshift transform to handle Vue SFC files.
|
|
4
|
+
* For .ts files: passes through directly.
|
|
5
|
+
* For .vue files: extracts <script setup> or <script> content, transforms it,
|
|
6
|
+
* then reconstructs the SFC using offset-based splicing.
|
|
7
|
+
*/
|
|
8
|
+
export declare function wrapForSFC(coreTransform: Transform): Transform;
|
|
9
|
+
/**
|
|
10
|
+
* Wraps a template-only transform for Vue SFC files.
|
|
11
|
+
* Returns null for non-.vue files.
|
|
12
|
+
*/
|
|
13
|
+
export declare function wrapForSFCTemplate(templateTransform: (template: string, filePath: string) => {
|
|
14
|
+
content: string;
|
|
15
|
+
changed: boolean;
|
|
16
|
+
}): Transform;
|
|
17
|
+
/**
|
|
18
|
+
* Wraps both a script transform and a template transform for Vue SFC files.
|
|
19
|
+
* Script transform runs first, then template transform on the (possibly modified) SFC.
|
|
20
|
+
*/
|
|
21
|
+
export declare function wrapForSFCBoth(scriptTransform: Transform, templateTransform: (template: string, filePath: string) => {
|
|
22
|
+
content: string;
|
|
23
|
+
changed: boolean;
|
|
24
|
+
}): Transform;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { parse as parseSFC } from "@vue/compiler-sfc";
|
|
2
|
+
/**
|
|
3
|
+
* Wraps a script-only jscodeshift transform to handle Vue SFC files.
|
|
4
|
+
* For .ts files: passes through directly.
|
|
5
|
+
* For .vue files: extracts <script setup> or <script> content, transforms it,
|
|
6
|
+
* then reconstructs the SFC using offset-based splicing.
|
|
7
|
+
*/
|
|
8
|
+
export function wrapForSFC(coreTransform) {
|
|
9
|
+
return (fileInfo, api, options) => {
|
|
10
|
+
if (!fileInfo.path.endsWith(".vue")) {
|
|
11
|
+
return coreTransform(fileInfo, api, options);
|
|
12
|
+
}
|
|
13
|
+
const { descriptor } = parseSFC(fileInfo.source, { filename: fileInfo.path });
|
|
14
|
+
const scriptBlock = descriptor.scriptSetup ?? descriptor.script;
|
|
15
|
+
if (!scriptBlock)
|
|
16
|
+
return null;
|
|
17
|
+
const scriptResult = coreTransform({ ...fileInfo, source: scriptBlock.content }, api, options);
|
|
18
|
+
if (scriptResult == null)
|
|
19
|
+
return null;
|
|
20
|
+
// Offset-based splicing — safe with $ characters
|
|
21
|
+
const start = scriptBlock.loc.start.offset;
|
|
22
|
+
const end = scriptBlock.loc.end.offset;
|
|
23
|
+
return (fileInfo.source.substring(0, start) +
|
|
24
|
+
scriptResult +
|
|
25
|
+
fileInfo.source.substring(end));
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Wraps a template-only transform for Vue SFC files.
|
|
30
|
+
* Returns null for non-.vue files.
|
|
31
|
+
*/
|
|
32
|
+
export function wrapForSFCTemplate(templateTransform) {
|
|
33
|
+
return (fileInfo, _api, _options) => {
|
|
34
|
+
if (!fileInfo.path.endsWith(".vue"))
|
|
35
|
+
return null;
|
|
36
|
+
const { descriptor } = parseSFC(fileInfo.source, { filename: fileInfo.path });
|
|
37
|
+
if (!descriptor.template)
|
|
38
|
+
return null;
|
|
39
|
+
const result = templateTransform(descriptor.template.content, fileInfo.path);
|
|
40
|
+
if (!result.changed)
|
|
41
|
+
return null;
|
|
42
|
+
const start = descriptor.template.loc.start.offset;
|
|
43
|
+
const end = descriptor.template.loc.end.offset;
|
|
44
|
+
return (fileInfo.source.substring(0, start) +
|
|
45
|
+
result.content +
|
|
46
|
+
fileInfo.source.substring(end));
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Wraps both a script transform and a template transform for Vue SFC files.
|
|
51
|
+
* Script transform runs first, then template transform on the (possibly modified) SFC.
|
|
52
|
+
*/
|
|
53
|
+
export function wrapForSFCBoth(scriptTransform, templateTransform) {
|
|
54
|
+
return (fileInfo, api, options) => {
|
|
55
|
+
const afterScript = wrapForSFC(scriptTransform)(fileInfo, api, options);
|
|
56
|
+
const source = afterScript ?? fileInfo.source;
|
|
57
|
+
const afterTemplate = wrapForSFCTemplate(templateTransform)({ ...fileInfo, source }, api, options);
|
|
58
|
+
return afterTemplate ?? afterScript;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=vue-sfc-wrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vue-sfc-wrapper.js","sourceRoot":"","sources":["../../src/utils/vue-sfc-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGtD;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,aAAwB;IACjD,OAAO,CAAC,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE;QAChC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YACpC,OAAO,aAAa,CAAC,QAAQ,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;QAC/C,CAAC;QACD,MAAM,EAAE,UAAU,EAAE,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;QAC9E,MAAM,WAAW,GAAG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UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC;QACnD,MAAM,GAAG,GAAG,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC;QAC/C,OAAO,CACL,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC;YACnC,MAAM,CAAC,OAAO;YACd,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAC/B,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAC5B,eAA0B,EAC1B,iBAAgG;IAEhG,OAAO,CAAC,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE;QAChC,MAAM,WAAW,GAAG,UAAU,CAAC,eAAe,CAAC,CAAC,QAAQ,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;QACxE,MAAM,MAAM,GAAG,WAAW,IAAI,QAAQ,CAAC,MAAM,CAAC;QAC9C,MAAM,aAAa,GAAG,kBAAkB,CAAC,iBAAiB,CAAC,CACzD,EAAE,GAAG,QAAQ,EAAE,MAAM,EAAE,EACvB,GAAG,EACH,OAAO,CACR,CAAC;QACF,OAAO,aAAa,IAAI,WAAW,CAAC;IACtC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function detectFrameworkVersion(cwd: string): string | null;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { readFileSync, existsSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import semver from "semver";
|
|
4
|
+
const FRAMEWORK_PKG = "@vc-shell/framework";
|
|
5
|
+
export function detectFrameworkVersion(cwd) {
|
|
6
|
+
const pkgPath = join(cwd, "package.json");
|
|
7
|
+
if (!existsSync(pkgPath))
|
|
8
|
+
return null;
|
|
9
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
10
|
+
const version = pkg.dependencies?.[FRAMEWORK_PKG] ??
|
|
11
|
+
pkg.devDependencies?.[FRAMEWORK_PKG] ??
|
|
12
|
+
pkg.peerDependencies?.[FRAMEWORK_PKG];
|
|
13
|
+
if (!version)
|
|
14
|
+
return null;
|
|
15
|
+
if (version.startsWith("workspace:")) {
|
|
16
|
+
return resolveFromNodeModules(cwd);
|
|
17
|
+
}
|
|
18
|
+
// For prerelease versions, minVersion preserves the prerelease tag
|
|
19
|
+
const min = semver.minVersion(version);
|
|
20
|
+
if (min)
|
|
21
|
+
return min.version;
|
|
22
|
+
const coerced = semver.coerce(version);
|
|
23
|
+
return coerced ? coerced.version : null;
|
|
24
|
+
}
|
|
25
|
+
function resolveFromNodeModules(cwd) {
|
|
26
|
+
const nmPkgPath = join(cwd, "node_modules", "@vc-shell", "framework", "package.json");
|
|
27
|
+
if (!existsSync(nmPkgPath))
|
|
28
|
+
return null;
|
|
29
|
+
const pkg = JSON.parse(readFileSync(nmPkgPath, "utf-8"));
|
|
30
|
+
return pkg.version ?? null;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=version-detector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version-detector.js","sourceRoot":"","sources":["../src/version-detector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,aAAa,GAAG,qBAAqB,CAAC;AAE5C,MAAM,UAAU,sBAAsB,CAAC,GAAW;IAChD,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;IAC1C,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAC;IAEtC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,O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|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"test": "vitest run",
|
|
13
|
+
"test:watch": "vitest"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@vue/compiler-sfc": "^3.5.30",
|
|
17
|
+
"chalk": "^5.0.0",
|
|
18
|
+
"commander": "^12.0.0",
|
|
19
|
+
"jscodeshift": "^17.3.0",
|
|
20
|
+
"jsonc-parser": "^3.3.1",
|
|
21
|
+
"semver": "^7.7.0",
|
|
22
|
+
"write-file-atomic": "^7.0.1"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/semver": "^7.7.1",
|
|
26
|
+
"typescript": "^5.8.3",
|
|
27
|
+
"vitest": "^3.0.0"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public",
|
|
31
|
+
"registry": "https://registry.npmjs.org/"
|
|
32
|
+
}
|
|
33
|
+
}
|