@varlet/cli 2.7.0-alpha.1673534139536 → 2.7.0-alpha.1673617166404
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/lib/node/bin.js +2 -4
- package/lib/node/commands/release.d.ts +1 -0
- package/lib/node/commands/release.js +5 -1
- package/lib/node/compiler/compileModule.js +1 -1
- package/lib/node/compiler/compileScript.d.ts +10 -13
- package/lib/node/compiler/compileScript.js +116 -32
- package/lib/node/compiler/compileStyle.js +1 -1
- package/lib/node/compiler/compileTemplateHighlight.js +4 -4
- package/lib/node/index.d.ts +12 -0
- package/lib/node/index.js +12 -0
- package/lib/node/shared/fsUtils.d.ts +2 -0
- package/lib/node/shared/fsUtils.js +8 -2
- package/package.json +7 -7
package/lib/node/bin.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import fse from 'fs-extra';
|
|
3
2
|
import { Command } from 'commander';
|
|
4
|
-
import {
|
|
5
|
-
const { readJSONSync } = fse;
|
|
3
|
+
import { getCliVersion } from './shared/fsUtils.js';
|
|
6
4
|
const program = new Command();
|
|
7
|
-
program.version(`varlet-cli ${
|
|
5
|
+
program.version(`varlet-cli ${getCliVersion()}`).usage('<command> [options]');
|
|
8
6
|
program
|
|
9
7
|
.command('dev')
|
|
10
8
|
.option('-f --force', 'Force dep pre-optimization regardless of whether deps have changed')
|
|
@@ -8,6 +8,7 @@ import inquirer from 'inquirer';
|
|
|
8
8
|
import { CWD } from '../shared/constant.js';
|
|
9
9
|
import { resolve } from 'path';
|
|
10
10
|
import { changelog } from './changelog.js';
|
|
11
|
+
import { getVersion } from '../shared/fsUtils.js';
|
|
11
12
|
const { writeFileSync, readJSONSync } = fse;
|
|
12
13
|
const { prompt } = inquirer;
|
|
13
14
|
const releaseTypes = ['premajor', 'preminor', 'prepatch', 'major', 'minor', 'patch'];
|
|
@@ -100,7 +101,7 @@ async function getReleaseType() {
|
|
|
100
101
|
}
|
|
101
102
|
export async function release(options) {
|
|
102
103
|
try {
|
|
103
|
-
const currentVersion =
|
|
104
|
+
const currentVersion = getVersion();
|
|
104
105
|
if (!currentVersion) {
|
|
105
106
|
logger.error('Your package is missing the version field');
|
|
106
107
|
return;
|
|
@@ -123,6 +124,9 @@ export async function release(options) {
|
|
|
123
124
|
return;
|
|
124
125
|
}
|
|
125
126
|
updateVersion(expectVersion);
|
|
127
|
+
if (options.task) {
|
|
128
|
+
await options.task();
|
|
129
|
+
}
|
|
126
130
|
await publish(isPreRelease);
|
|
127
131
|
if (!isPreRelease) {
|
|
128
132
|
await changelog();
|
|
@@ -50,7 +50,7 @@ export async function compileModule() {
|
|
|
50
50
|
const moduleDir = await readdir(dest);
|
|
51
51
|
await Promise.all(moduleDir.map((filename) => {
|
|
52
52
|
const file = resolve(dest, filename);
|
|
53
|
-
isDir(file) && ensureFileSync(resolve(file, `./style/index
|
|
53
|
+
isDir(file) && ensureFileSync(resolve(file, `./style/index${getScriptExtname()}`));
|
|
54
54
|
return isDir(file) ? compileDir(file) : null;
|
|
55
55
|
}));
|
|
56
56
|
const publicDirs = await getPublicDirs();
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const replaceTSExt: (script: string) => string;
|
|
11
|
-
export declare const replaceJSXExt: (script: string) => string;
|
|
12
|
-
export declare const replaceTSXExt: (script: string) => string;
|
|
1
|
+
export declare const IMPORT_FROM_DEPENDENCE_RE: RegExp;
|
|
2
|
+
export declare const IMPORT_DEPENDENCE_RE: RegExp;
|
|
3
|
+
export declare const REQUIRE_DEPENDENCE_RE: RegExp;
|
|
4
|
+
export declare const scriptExtNames: string[];
|
|
5
|
+
export declare const styleExtNames: string[];
|
|
6
|
+
export declare const scriptIndexes: string[];
|
|
7
|
+
export declare const styleIndexes: string[];
|
|
8
|
+
export declare const tryMatchExtname: (file: string, extname: string[]) => string | undefined;
|
|
9
|
+
export declare const resolveDependence: (file: string, script: string) => string;
|
|
13
10
|
export declare const moduleCompatible: (script: string) => Promise<string>;
|
|
14
11
|
export declare function compileScript(script: string, file: string): Promise<void>;
|
|
15
12
|
export declare function compileScriptFile(file: string): Promise<void>;
|
|
16
|
-
export declare function getScriptExtname(): "
|
|
13
|
+
export declare function getScriptExtname(): ".js" | ".mjs";
|
|
17
14
|
export declare function compileESEntry(dir: string, publicDirs: string[]): Promise<void>;
|
|
18
15
|
export declare function compileCommonJSEntry(dir: string, publicDirs: string[]): Promise<void>;
|
|
@@ -1,25 +1,85 @@
|
|
|
1
1
|
import fse from 'fs-extra';
|
|
2
2
|
import { transformAsync } from '@babel/core';
|
|
3
3
|
import { bigCamelize } from '@varlet/shared';
|
|
4
|
-
import { replaceExt } from '../shared/fsUtils.js';
|
|
4
|
+
import { getVersion, isDir, replaceExt } from '../shared/fsUtils.js';
|
|
5
5
|
import { extractStyleDependencies, IMPORT_CSS_RE, IMPORT_LESS_RE, REQUIRE_CSS_RE, REQUIRE_LESS_RE, } from './compileStyle.js';
|
|
6
|
-
import { resolve } from 'path';
|
|
6
|
+
import { resolve, extname, dirname } from 'path';
|
|
7
7
|
import { get } from 'lodash-es';
|
|
8
8
|
import { getVarletConfig } from '../config/varlet.config.js';
|
|
9
|
-
const { writeFileSync, readFileSync, removeSync, writeFile } = fse;
|
|
10
|
-
|
|
11
|
-
export const
|
|
12
|
-
|
|
13
|
-
export const
|
|
14
|
-
|
|
15
|
-
export const
|
|
16
|
-
export const
|
|
17
|
-
export const
|
|
18
|
-
const
|
|
19
|
-
export const
|
|
20
|
-
export const
|
|
21
|
-
|
|
22
|
-
|
|
9
|
+
const { writeFileSync, readdirSync, readFileSync, removeSync, writeFile, pathExistsSync } = fse;
|
|
10
|
+
// https://regexr.com/765a4
|
|
11
|
+
export const IMPORT_FROM_DEPENDENCE_RE = /import\s+?[\w\s{},$*]+\s+from\s+?(".*?"|'.*?')/g;
|
|
12
|
+
// https://regexr.com/764ve
|
|
13
|
+
export const IMPORT_DEPENDENCE_RE = /import\s+(".*?"|'.*?')/g;
|
|
14
|
+
// https://regexr.com/764vn
|
|
15
|
+
export const REQUIRE_DEPENDENCE_RE = /require\((".*?"|'.*?')\)/g;
|
|
16
|
+
export const scriptExtNames = ['.vue', '.ts', '.tsx', '.mjs', '.js', '.jsx'];
|
|
17
|
+
export const styleExtNames = ['.less', '.css'];
|
|
18
|
+
export const scriptIndexes = ['index.mjs', 'index.vue', 'index.ts', 'index.tsx', 'index.js', 'index.jsx'];
|
|
19
|
+
export const styleIndexes = ['index.less', 'index.css'];
|
|
20
|
+
export const tryMatchExtname = (file, extname) => {
|
|
21
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
22
|
+
for (const ext of extname) {
|
|
23
|
+
const matched = `${file}${ext}`;
|
|
24
|
+
if (pathExistsSync(matched)) {
|
|
25
|
+
return ext;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
export const resolveDependence = (file, script) => {
|
|
30
|
+
const replacer = (source, dependence) => {
|
|
31
|
+
dependence = dependence.slice(1, dependence.length - 1);
|
|
32
|
+
const ext = extname(dependence);
|
|
33
|
+
const targetDependenceFile = resolve(dirname(file), dependence);
|
|
34
|
+
const scriptExtname = getScriptExtname();
|
|
35
|
+
const inNodeModules = !dependence.startsWith('.');
|
|
36
|
+
const done = (targetDependence) => source.replace(dependence, targetDependence);
|
|
37
|
+
if (inNodeModules) {
|
|
38
|
+
// e.g. @varlet/shared
|
|
39
|
+
return source;
|
|
40
|
+
}
|
|
41
|
+
if (ext) {
|
|
42
|
+
if (scriptExtNames.includes(ext)) {
|
|
43
|
+
// e.g. './a.vue' -> './a.m?js'
|
|
44
|
+
return done(dependence.replace(ext, scriptExtname));
|
|
45
|
+
}
|
|
46
|
+
if (styleExtNames.includes(ext)) {
|
|
47
|
+
// e.g. './a.css' -> './a.css' './a.less' -> './a.less'
|
|
48
|
+
return source;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (!ext) {
|
|
52
|
+
// e.g. ../button/props -> ../button/props.m?js
|
|
53
|
+
const matchedScript = tryMatchExtname(targetDependenceFile, scriptExtNames);
|
|
54
|
+
if (matchedScript) {
|
|
55
|
+
return done(`${dependence}${scriptExtname}`);
|
|
56
|
+
}
|
|
57
|
+
const matchedStyle = tryMatchExtname(targetDependenceFile, styleExtNames);
|
|
58
|
+
if (matchedStyle) {
|
|
59
|
+
return done(`${dependence}${matchedStyle}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (!ext && isDir(targetDependenceFile)) {
|
|
63
|
+
// e.g. ../button
|
|
64
|
+
const files = readdirSync(targetDependenceFile);
|
|
65
|
+
const hasScriptIndex = files.some((file) => scriptIndexes.some((name) => file.endsWith(name)));
|
|
66
|
+
if (hasScriptIndex) {
|
|
67
|
+
// e.g. -> ../button/index.m?js
|
|
68
|
+
return done(`${dependence}/index${scriptExtname}`);
|
|
69
|
+
}
|
|
70
|
+
const hasStyleIndex = files.some((file) => styleIndexes.some((name) => file.endsWith(name)));
|
|
71
|
+
if (hasStyleIndex) {
|
|
72
|
+
// e.g. -> ../button/index.css
|
|
73
|
+
return done(`${dependence}/index.css`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return '';
|
|
77
|
+
};
|
|
78
|
+
return script
|
|
79
|
+
.replace(IMPORT_FROM_DEPENDENCE_RE, replacer)
|
|
80
|
+
.replace(IMPORT_DEPENDENCE_RE, replacer)
|
|
81
|
+
.replace(REQUIRE_DEPENDENCE_RE, replacer);
|
|
82
|
+
};
|
|
23
83
|
export const moduleCompatible = async (script) => {
|
|
24
84
|
const moduleCompatible = get(await getVarletConfig(), 'moduleCompatible', {});
|
|
25
85
|
Object.keys(moduleCompatible).forEach((esm) => {
|
|
@@ -36,14 +96,13 @@ export async function compileScript(script, file) {
|
|
|
36
96
|
let { code } = (await transformAsync(script, {
|
|
37
97
|
filename: file,
|
|
38
98
|
}));
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
writeFileSync(replaceExt(file, `.${getScriptExtname()}`), code, 'utf8');
|
|
99
|
+
if (code) {
|
|
100
|
+
code = resolveDependence(file, code);
|
|
101
|
+
code = extractStyleDependencies(file, code, targetModule === 'commonjs' ? REQUIRE_CSS_RE : IMPORT_CSS_RE);
|
|
102
|
+
code = extractStyleDependencies(file, code, targetModule === 'commonjs' ? REQUIRE_LESS_RE : IMPORT_LESS_RE);
|
|
103
|
+
removeSync(file);
|
|
104
|
+
writeFileSync(replaceExt(file, getScriptExtname()), code, 'utf8');
|
|
105
|
+
}
|
|
47
106
|
}
|
|
48
107
|
export async function compileScriptFile(file) {
|
|
49
108
|
const sources = readFileSync(file, 'utf-8');
|
|
@@ -51,40 +110,45 @@ export async function compileScriptFile(file) {
|
|
|
51
110
|
}
|
|
52
111
|
export function getScriptExtname() {
|
|
53
112
|
if (process.env.TARGET_MODULE === 'module') {
|
|
54
|
-
return 'mjs';
|
|
113
|
+
return '.mjs';
|
|
55
114
|
}
|
|
56
|
-
return 'js';
|
|
115
|
+
return '.js';
|
|
57
116
|
}
|
|
58
117
|
export async function compileESEntry(dir, publicDirs) {
|
|
59
118
|
const imports = [];
|
|
60
119
|
const plugins = [];
|
|
61
|
-
const
|
|
120
|
+
const exports = [];
|
|
62
121
|
const cssImports = [];
|
|
63
122
|
const publicComponents = [];
|
|
64
123
|
const scriptExtname = getScriptExtname();
|
|
65
124
|
publicDirs.forEach((dirname) => {
|
|
66
125
|
const publicComponent = bigCamelize(dirname);
|
|
126
|
+
const module = `'./${dirname}/index${scriptExtname}'`;
|
|
67
127
|
publicComponents.push(publicComponent);
|
|
68
|
-
imports.push(`import ${publicComponent}
|
|
69
|
-
|
|
128
|
+
imports.push(`import ${publicComponent} from ${module}`);
|
|
129
|
+
exports.push(`export * from ${module}`);
|
|
70
130
|
plugins.push(`${publicComponent}.install && app.use(${publicComponent})`);
|
|
71
|
-
cssImports.push(`import './${dirname}/style/index
|
|
131
|
+
cssImports.push(`import './${dirname}/style/index${scriptExtname}'`);
|
|
72
132
|
});
|
|
73
133
|
const install = `
|
|
74
134
|
function install(app) {
|
|
75
135
|
${plugins.join('\n ')}
|
|
76
136
|
}
|
|
77
137
|
`;
|
|
138
|
+
const version = `const version = '${getVersion()}'`;
|
|
78
139
|
const indexTemplate = `\
|
|
79
140
|
${imports.join('\n')}\n
|
|
80
|
-
${
|
|
141
|
+
${exports.join('\n')}\n
|
|
142
|
+
${version}
|
|
81
143
|
${install}
|
|
82
144
|
export {
|
|
145
|
+
version,
|
|
83
146
|
install,
|
|
84
147
|
${publicComponents.join(',\n ')}
|
|
85
148
|
}
|
|
86
149
|
|
|
87
150
|
export default {
|
|
151
|
+
version,
|
|
88
152
|
install,
|
|
89
153
|
${publicComponents.join(',\n ')}
|
|
90
154
|
}
|
|
@@ -95,13 +159,16 @@ ${cssImports.join('\n')}
|
|
|
95
159
|
const umdTemplate = `\
|
|
96
160
|
${imports.join('\n')}\n
|
|
97
161
|
${cssImports.join('\n')}\n
|
|
162
|
+
${version}
|
|
98
163
|
${install}
|
|
99
164
|
export {
|
|
165
|
+
version,
|
|
100
166
|
install,
|
|
101
167
|
${publicComponents.join(',\n ')}
|
|
102
168
|
}
|
|
103
169
|
|
|
104
170
|
export default {
|
|
171
|
+
version,
|
|
105
172
|
install,
|
|
106
173
|
${publicComponents.join(',\n ')}
|
|
107
174
|
}
|
|
@@ -117,13 +184,17 @@ export async function compileCommonJSEntry(dir, publicDirs) {
|
|
|
117
184
|
const plugins = [];
|
|
118
185
|
const cssRequires = [];
|
|
119
186
|
const publicComponents = [];
|
|
187
|
+
const exports = [];
|
|
120
188
|
publicDirs.forEach((dirname) => {
|
|
121
189
|
const publicComponent = bigCamelize(dirname);
|
|
190
|
+
const module = `'./${dirname}/index.js'`;
|
|
122
191
|
publicComponents.push(publicComponent);
|
|
123
|
-
requires.push(`var ${publicComponent} = require(
|
|
192
|
+
requires.push(`var ${publicComponent} = require(${module})['default']`);
|
|
193
|
+
exports.push(`...ignoreDefault(require(${module}))`);
|
|
124
194
|
plugins.push(`${publicComponent}.install && app.use(${publicComponent})`);
|
|
125
195
|
cssRequires.push(`require('./${dirname}/style/index.js')`);
|
|
126
196
|
});
|
|
197
|
+
const version = `const version = '${getVersion()}'`;
|
|
127
198
|
const install = `
|
|
128
199
|
function install(app) {
|
|
129
200
|
${plugins.join('\n ')}
|
|
@@ -131,10 +202,23 @@ function install(app) {
|
|
|
131
202
|
`;
|
|
132
203
|
const indexTemplate = `\
|
|
133
204
|
${requires.join('\n')}\n
|
|
205
|
+
${version}
|
|
134
206
|
${install}
|
|
135
207
|
|
|
208
|
+
function ignoreDefault(module) {
|
|
209
|
+
return Object.keys(module).reduce((exports, key) => {
|
|
210
|
+
if (key !== 'default') {
|
|
211
|
+
exports[key] = module[key]
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return exports
|
|
215
|
+
}, {})
|
|
216
|
+
}
|
|
217
|
+
|
|
136
218
|
module.exports = {
|
|
219
|
+
version,
|
|
137
220
|
install,
|
|
221
|
+
${exports.join(',\n ')},
|
|
138
222
|
${publicComponents.join(',\n ')}
|
|
139
223
|
}
|
|
140
224
|
`;
|
|
@@ -25,7 +25,7 @@ export function normalizeStyleDependency(styleImport, reg) {
|
|
|
25
25
|
export function extractStyleDependencies(file, code, styleReg) {
|
|
26
26
|
var _a;
|
|
27
27
|
const styleImports = (_a = code.match(styleReg)) !== null && _a !== void 0 ? _a : [];
|
|
28
|
-
const cssFile = resolve(parse(file).dir, `./style/index
|
|
28
|
+
const cssFile = resolve(parse(file).dir, `./style/index${getScriptExtname()}`);
|
|
29
29
|
const targetModule = process.env.TARGET_MODULE;
|
|
30
30
|
styleImports.forEach((styleImport) => {
|
|
31
31
|
const normalizedPath = normalizeStyleDependency(styleImport, styleReg);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import fse from 'fs-extra';
|
|
2
|
-
import { SRC_DIR, HL_MD, HL_API_RE, HL_COMPONENT_NAME_RE, HL_TITLE_ATTRIBUTES_RE, HL_TITLE_EVENTS_RE, HL_TITLE_SLOTS_RE, HL_WEB_TYPES_JSON, HL_DIR, HL_TAGS_JSON, HL_ATTRIBUTES_JSON,
|
|
2
|
+
import { SRC_DIR, HL_MD, HL_API_RE, HL_COMPONENT_NAME_RE, HL_TITLE_ATTRIBUTES_RE, HL_TITLE_EVENTS_RE, HL_TITLE_SLOTS_RE, HL_WEB_TYPES_JSON, HL_DIR, HL_TAGS_JSON, HL_ATTRIBUTES_JSON, } from '../shared/constant.js';
|
|
3
3
|
import { resolve } from 'path';
|
|
4
|
-
import { isDir, isMD } from '../shared/fsUtils.js';
|
|
4
|
+
import { getCliVersion, isDir, isMD } from '../shared/fsUtils.js';
|
|
5
5
|
import { get } from 'lodash-es';
|
|
6
6
|
import { getVarletConfig } from '../config/varlet.config.js';
|
|
7
|
-
const { ensureDir, readdirSync, readFileSync,
|
|
7
|
+
const { ensureDir, readdirSync, readFileSync, writeFile } = fse;
|
|
8
8
|
const TABLE_HEAD_RE = /\s*\|.*\|\s*\n\s*\|.*---+\s*\|\s*\n+/;
|
|
9
9
|
const TABLE_FOOT_RE = /(\|\s*$)|(\|\s*\n(?!\s*\|))/;
|
|
10
10
|
export const replaceDot = (s) => s.replace(/`/g, '');
|
|
@@ -115,7 +115,7 @@ export async function compileTemplateHighlight() {
|
|
|
115
115
|
const webTypes = {
|
|
116
116
|
$schema: 'https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json',
|
|
117
117
|
framework: 'vue',
|
|
118
|
-
version:
|
|
118
|
+
version: getCliVersion(),
|
|
119
119
|
name: get(varletConfig, 'title'),
|
|
120
120
|
contributions: {
|
|
121
121
|
html: {
|
package/lib/node/index.d.ts
CHANGED
|
@@ -1 +1,13 @@
|
|
|
1
1
|
export { defineConfig } from './config/varlet.config.js';
|
|
2
|
+
export * from './commands/release.js';
|
|
3
|
+
export * from './commands/dev.js';
|
|
4
|
+
export * from './commands/build.js';
|
|
5
|
+
export * from './commands/compile.js';
|
|
6
|
+
export * from './commands/commitLint.js';
|
|
7
|
+
export * from './commands/gen.js';
|
|
8
|
+
export * from './commands/jest.js';
|
|
9
|
+
export * from './commands/create.js';
|
|
10
|
+
export * from './commands/lint.js';
|
|
11
|
+
export * from './commands/changelog.js';
|
|
12
|
+
export * from './commands/preview.js';
|
|
13
|
+
export * from './commands/vite.js';
|
package/lib/node/index.js
CHANGED
|
@@ -1 +1,13 @@
|
|
|
1
1
|
export { defineConfig } from './config/varlet.config.js';
|
|
2
|
+
export * from './commands/release.js';
|
|
3
|
+
export * from './commands/dev.js';
|
|
4
|
+
export * from './commands/build.js';
|
|
5
|
+
export * from './commands/compile.js';
|
|
6
|
+
export * from './commands/commitLint.js';
|
|
7
|
+
export * from './commands/gen.js';
|
|
8
|
+
export * from './commands/jest.js';
|
|
9
|
+
export * from './commands/create.js';
|
|
10
|
+
export * from './commands/lint.js';
|
|
11
|
+
export * from './commands/changelog.js';
|
|
12
|
+
export * from './commands/preview.js';
|
|
13
|
+
export * from './commands/vite.js';
|
|
@@ -11,3 +11,5 @@ export declare function smartAppendFileSync(file: string, code: string): void;
|
|
|
11
11
|
export declare function outputFileSyncOnChange(path: string, code: string): void;
|
|
12
12
|
export declare function glob(pattern: string): Promise<string[]>;
|
|
13
13
|
export declare function getDirname(url: string): string;
|
|
14
|
+
export declare function getVersion(): any;
|
|
15
|
+
export declare function getCliVersion(): any;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import globSync from 'glob';
|
|
2
2
|
import fse from 'fs-extra';
|
|
3
3
|
import { extname, resolve } from 'path';
|
|
4
|
-
import { PUBLIC_DIR_INDEXES, SCRIPTS_EXTENSIONS, SRC_DIR } from './constant.js';
|
|
4
|
+
import { CLI_PACKAGE_JSON, PUBLIC_DIR_INDEXES, SCRIPTS_EXTENSIONS, SRC_DIR, UI_PACKAGE_JSON } from './constant.js';
|
|
5
5
|
import { fileURLToPath } from 'url';
|
|
6
|
-
const { appendFileSync, ensureFileSync, lstatSync, outputFileSync, pathExistsSync, readdir, readFileSync } = fse;
|
|
6
|
+
const { appendFileSync, ensureFileSync, lstatSync, outputFileSync, pathExistsSync, readdir, readFileSync, readJSONSync, } = fse;
|
|
7
7
|
export async function getPublicDirs() {
|
|
8
8
|
const srcDir = await readdir(SRC_DIR);
|
|
9
9
|
return srcDir.filter((filename) => isPublicDir(resolve(SRC_DIR, filename)));
|
|
@@ -46,3 +46,9 @@ export function glob(pattern) {
|
|
|
46
46
|
export function getDirname(url) {
|
|
47
47
|
return fileURLToPath(new URL('.', url));
|
|
48
48
|
}
|
|
49
|
+
export function getVersion() {
|
|
50
|
+
return readJSONSync(UI_PACKAGE_JSON).version;
|
|
51
|
+
}
|
|
52
|
+
export function getCliVersion() {
|
|
53
|
+
return readJSONSync(CLI_PACKAGE_JSON).version;
|
|
54
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varlet/cli",
|
|
3
|
-
"version": "2.7.0-alpha.
|
|
3
|
+
"version": "2.7.0-alpha.1673617166404",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "cli of varlet",
|
|
6
6
|
"bin": {
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
"vite": "4.0.4",
|
|
67
67
|
"vue": "3.2.25",
|
|
68
68
|
"vue-jest": "^5.0.0-alpha.8",
|
|
69
|
-
"@varlet/vite-plugins": "2.7.0-alpha.
|
|
70
|
-
"@varlet/shared": "2.7.0-alpha.
|
|
69
|
+
"@varlet/vite-plugins": "2.7.0-alpha.1673617166404",
|
|
70
|
+
"@varlet/shared": "2.7.0-alpha.1673617166404"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@types/babel__core": "^7.1.12",
|
|
@@ -79,8 +79,8 @@
|
|
|
79
79
|
"@types/node": "^18.7.20",
|
|
80
80
|
"@types/semver": "^7.3.9",
|
|
81
81
|
"@types/inquirer": "^9.0.2",
|
|
82
|
-
"@varlet/
|
|
83
|
-
"@varlet/
|
|
82
|
+
"@varlet/touch-emulator": "2.7.0-alpha.1673617166404",
|
|
83
|
+
"@varlet/icons": "2.7.0-alpha.1673617166404"
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
86
|
"@vue/runtime-core": "3.2.16",
|
|
@@ -90,8 +90,8 @@
|
|
|
90
90
|
"lodash-es": "^4.17.21",
|
|
91
91
|
"vue": "3.2.25",
|
|
92
92
|
"vue-router": "4.0.12",
|
|
93
|
-
"@varlet/icons": "2.7.0-alpha.
|
|
94
|
-
"@varlet/touch-emulator": "2.7.0-alpha.
|
|
93
|
+
"@varlet/icons": "2.7.0-alpha.1673617166404",
|
|
94
|
+
"@varlet/touch-emulator": "2.7.0-alpha.1673617166404"
|
|
95
95
|
},
|
|
96
96
|
"scripts": {
|
|
97
97
|
"dev": "tsc --watch",
|