@varlet/cli 2.1.0-alpha.1667210582672 ā 2.1.0
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/client/appType.d.ts +4 -4
- package/lib/client/appType.js +7 -7
- package/lib/client/index.d.ts +17 -17
- package/lib/client/index.js +106 -106
- package/lib/node/bin.d.ts +2 -2
- package/lib/node/bin.js +122 -122
- package/lib/node/commands/build.d.ts +1 -1
- package/lib/node/commands/build.js +15 -15
- package/lib/node/commands/changelog.d.ts +6 -6
- package/lib/node/commands/changelog.js +20 -20
- package/lib/node/commands/commitLint.d.ts +1 -1
- package/lib/node/commands/commitLint.js +16 -16
- package/lib/node/commands/compile.d.ts +7 -7
- package/lib/node/commands/compile.js +35 -35
- package/lib/node/commands/create.d.ts +8 -8
- package/lib/node/commands/create.js +91 -91
- package/lib/node/commands/dev.d.ts +5 -5
- package/lib/node/commands/dev.js +38 -38
- package/lib/node/commands/gen.d.ts +8 -8
- package/lib/node/commands/gen.js +69 -68
- package/lib/node/commands/jest.d.ts +8 -8
- package/lib/node/commands/jest.js +27 -27
- package/lib/node/commands/lint.d.ts +1 -1
- package/lib/node/commands/lint.js +42 -42
- package/lib/node/commands/preview.d.ts +1 -1
- package/lib/node/commands/preview.js +18 -18
- package/lib/node/commands/release.d.ts +5 -5
- package/lib/node/commands/release.js +146 -146
- package/lib/node/commands/vite.d.ts +3 -3
- package/lib/node/commands/vite.js +13 -13
- package/lib/node/compiler/compileModule.d.ts +5 -5
- package/lib/node/compiler/compileModule.js +74 -74
- package/lib/node/compiler/compileSFC.d.ts +2 -2
- package/lib/node/compiler/compileSFC.js +74 -74
- package/lib/node/compiler/compileScript.d.ts +17 -17
- package/lib/node/compiler/compileScript.js +95 -95
- package/lib/node/compiler/compileSiteEntry.d.ts +13 -13
- package/lib/node/compiler/compileSiteEntry.js +95 -95
- package/lib/node/compiler/compileStyle.d.ts +11 -11
- package/lib/node/compiler/compileStyle.js +39 -39
- package/lib/node/compiler/compileTemplateHighlight.d.ts +10 -10
- package/lib/node/compiler/compileTemplateHighlight.js +133 -133
- package/lib/node/compiler/compileTypes.d.ts +2 -2
- package/lib/node/compiler/compileTypes.js +30 -30
- package/lib/node/config/varlet.config.d.ts +45 -45
- package/lib/node/config/varlet.config.js +27 -27
- package/lib/node/config/varlet.default.config.d.ts +2 -2
- package/lib/node/config/varlet.default.config.js +264 -264
- package/lib/node/config/vite.config.d.ts +6 -6
- package/lib/node/config/vite.config.js +142 -142
- package/lib/node/index.d.ts +1 -1
- package/lib/node/index.js +1 -1
- package/lib/node/shared/constant.d.ts +42 -42
- package/lib/node/shared/constant.js +47 -47
- package/lib/node/shared/fsUtils.d.ts +13 -13
- package/lib/node/shared/fsUtils.js +48 -48
- package/lib/node/shared/logger.d.ts +8 -8
- package/lib/node/shared/logger.js +18 -18
- package/package.json +7 -7
- package/site/components/button/index.ts +10 -10
- package/site/components/cell/index.ts +10 -10
- package/site/components/code-example/codeExample.less +41 -41
- package/site/components/code-example/index.ts +10 -10
- package/site/components/context/zIndex.ts +20 -20
- package/site/components/icon/icon.less +26 -26
- package/site/components/icon/index.ts +10 -10
- package/site/components/icon/props.ts +24 -24
- package/site/components/loading/index.ts +10 -10
- package/site/components/progress/index.ts +10 -10
- package/site/components/snackbar/snackbar.less +135 -135
- package/site/components/styles/common.less +64 -64
- package/site/components/styles/elevation.less +126 -126
- package/site/components/styles/var.less +27 -27
- package/site/index.html +49 -49
- package/site/mobile/components/app-bar/index.ts +10 -10
- package/site/mobile/components/app-bar/props.ts +25 -25
- package/site/mobile.html +41 -41
- package/site/module.d.ts +5 -5
- package/site/tsconfig.json +11 -11
- package/template/create/example/index.vue.ejs +4 -2
- package/template/generators/base/_gitignore +5 -1
- package/template/generators/base/babel.config.js +1 -1
- package/template/generators/config/default/sfc/src/button/example/index.vue +1 -1
- package/template/generators/config/default/tsx/src/button/example/index.vue +1 -1
- package/template/generators/config/i18n/sfc/src/button/example/BasicUse.vue +1 -1
- package/template/generators/config/i18n/sfc/src/button/example/ModifyColor.vue +1 -1
- package/template/generators/config/i18n/sfc/src/button/example/index.vue +1 -2
- package/template/generators/config/i18n/tsx/src/button/example/BasicUse.vue +1 -1
- package/template/generators/config/i18n/tsx/src/button/example/ModifyColor.vue +1 -1
- package/template/generators/config/i18n/tsx/src/button/example/index.vue +1 -2
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import logger from '../shared/logger.js';
|
|
2
|
-
import semver from 'semver';
|
|
3
|
-
import fse from 'fs-extra';
|
|
4
|
-
const { readFileSync } = fse;
|
|
5
|
-
function isVersion(message) {
|
|
6
|
-
return message.startsWith('v') && semver.valid(message.slice(1));
|
|
7
|
-
}
|
|
8
|
-
export function commitLint(gitParams) {
|
|
9
|
-
const message = readFileSync(gitParams, 'utf-8').trim();
|
|
10
|
-
const COMMIT_MESSAGE_RE = /^(revert|fix|feat|docs|perf|test|types|style|build|chore|release|refactor)(\(.+\))?!?: (.|\n)+/;
|
|
11
|
-
if (!isVersion(message) && !COMMIT_MESSAGE_RE.test(message)) {
|
|
12
|
-
logger.error(`Commit message invalid`);
|
|
1
|
+
import logger from '../shared/logger.js';
|
|
2
|
+
import semver from 'semver';
|
|
3
|
+
import fse from 'fs-extra';
|
|
4
|
+
const { readFileSync } = fse;
|
|
5
|
+
function isVersion(message) {
|
|
6
|
+
return message.startsWith('v') && semver.valid(message.slice(1));
|
|
7
|
+
}
|
|
8
|
+
export function commitLint(gitParams) {
|
|
9
|
+
const message = readFileSync(gitParams, 'utf-8').trim();
|
|
10
|
+
const COMMIT_MESSAGE_RE = /^(revert|fix|feat|docs|perf|test|types|style|build|chore|release|refactor)(\(.+\))?!?: (.|\n)+/;
|
|
11
|
+
if (!isVersion(message) && !COMMIT_MESSAGE_RE.test(message)) {
|
|
12
|
+
logger.error(`Commit message invalid`);
|
|
13
13
|
logger.warning(`\
|
|
14
14
|
The rules for commit messages are as follows
|
|
15
15
|
|
|
@@ -39,7 +39,7 @@ Allowed types:
|
|
|
39
39
|
- revert
|
|
40
40
|
|
|
41
41
|
Commit message reference: https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y
|
|
42
|
-
åčé®äøå³°Commit messageē¼åęå: https://www.ruanyifeng.com/blog/2016/01/commit_message_change_log.html`);
|
|
43
|
-
process.exit(1);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
42
|
+
åčé®äøå³°Commit messageē¼åęå: https://www.ruanyifeng.com/blog/2016/01/commit_message_change_log.html`);
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export declare function removeDir(): Promise<[void, void, void, void]>;
|
|
2
|
-
export declare function runTask(taskName: string, task: () => any): Promise<void>;
|
|
3
|
-
interface CompileCommandOptions {
|
|
4
|
-
noUmd?: boolean;
|
|
5
|
-
}
|
|
6
|
-
export declare function compile(options: CompileCommandOptions): Promise<void>;
|
|
7
|
-
export {};
|
|
1
|
+
export declare function removeDir(): Promise<[void, void, void, void]>;
|
|
2
|
+
export declare function runTask(taskName: string, task: () => any): Promise<void>;
|
|
3
|
+
interface CompileCommandOptions {
|
|
4
|
+
noUmd?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function compile(options: CompileCommandOptions): Promise<void>;
|
|
7
|
+
export {};
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import ora from 'ora';
|
|
2
|
-
import logger from '../shared/logger.js';
|
|
3
|
-
import fse from 'fs-extra';
|
|
4
|
-
import { ES_DIR, HL_DIR, LIB_DIR, UMD_DIR } from '../shared/constant.js';
|
|
5
|
-
import { compileModule } from '../compiler/compileModule.js';
|
|
6
|
-
import { compileTemplateHighlight } from '../compiler/compileTemplateHighlight.js';
|
|
7
|
-
import { compileTypes } from '../compiler/compileTypes.js';
|
|
8
|
-
const { remove } = fse;
|
|
9
|
-
export function removeDir() {
|
|
10
|
-
return Promise.all([remove(ES_DIR), remove(LIB_DIR), remove(HL_DIR), remove(UMD_DIR)]);
|
|
11
|
-
}
|
|
12
|
-
export async function runTask(taskName, task) {
|
|
13
|
-
const s = ora().start(`Compiling ${taskName}`);
|
|
14
|
-
try {
|
|
15
|
-
await task();
|
|
16
|
-
s.succeed(`Compilation ${taskName} completed!`);
|
|
17
|
-
}
|
|
18
|
-
catch (e) {
|
|
19
|
-
s.fail(`Compilation ${taskName} failed!`);
|
|
20
|
-
logger.error(e.toString());
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
export async function compile(options) {
|
|
24
|
-
process.env.NODE_ENV = 'compile';
|
|
25
|
-
await removeDir();
|
|
26
|
-
await Promise.all([runTask('types', compileTypes), runTask('template highlight', compileTemplateHighlight)]);
|
|
27
|
-
process.env.TARGET_MODULE = 'module';
|
|
28
|
-
await runTask('module', compileModule);
|
|
29
|
-
process.env.TARGET_MODULE = 'esm-bundle';
|
|
30
|
-
await runTask('esm bundle', () => compileModule('esm-bundle'));
|
|
31
|
-
process.env.TARGET_MODULE = 'commonjs';
|
|
32
|
-
await runTask('commonjs', () => compileModule('commonjs'));
|
|
33
|
-
process.env.TARGET_MODULE = 'umd';
|
|
34
|
-
!options.noUmd && (await runTask('umd', () => compileModule('umd')));
|
|
35
|
-
}
|
|
1
|
+
import ora from 'ora';
|
|
2
|
+
import logger from '../shared/logger.js';
|
|
3
|
+
import fse from 'fs-extra';
|
|
4
|
+
import { ES_DIR, HL_DIR, LIB_DIR, UMD_DIR } from '../shared/constant.js';
|
|
5
|
+
import { compileModule } from '../compiler/compileModule.js';
|
|
6
|
+
import { compileTemplateHighlight } from '../compiler/compileTemplateHighlight.js';
|
|
7
|
+
import { compileTypes } from '../compiler/compileTypes.js';
|
|
8
|
+
const { remove } = fse;
|
|
9
|
+
export function removeDir() {
|
|
10
|
+
return Promise.all([remove(ES_DIR), remove(LIB_DIR), remove(HL_DIR), remove(UMD_DIR)]);
|
|
11
|
+
}
|
|
12
|
+
export async function runTask(taskName, task) {
|
|
13
|
+
const s = ora().start(`Compiling ${taskName}`);
|
|
14
|
+
try {
|
|
15
|
+
await task();
|
|
16
|
+
s.succeed(`Compilation ${taskName} completed!`);
|
|
17
|
+
}
|
|
18
|
+
catch (e) {
|
|
19
|
+
s.fail(`Compilation ${taskName} failed!`);
|
|
20
|
+
logger.error(e.toString());
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export async function compile(options) {
|
|
24
|
+
process.env.NODE_ENV = 'compile';
|
|
25
|
+
await removeDir();
|
|
26
|
+
await Promise.all([runTask('types', compileTypes), runTask('template highlight', compileTemplateHighlight)]);
|
|
27
|
+
process.env.TARGET_MODULE = 'module';
|
|
28
|
+
await runTask('module', compileModule);
|
|
29
|
+
process.env.TARGET_MODULE = 'esm-bundle';
|
|
30
|
+
await runTask('esm bundle', () => compileModule('esm-bundle'));
|
|
31
|
+
process.env.TARGET_MODULE = 'commonjs';
|
|
32
|
+
await runTask('commonjs', () => compileModule('commonjs'));
|
|
33
|
+
process.env.TARGET_MODULE = 'umd';
|
|
34
|
+
!options.noUmd && (await runTask('umd', () => compileModule('umd')));
|
|
35
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
interface CreateCommandOptions {
|
|
2
|
-
name?: string;
|
|
3
|
-
locale?: boolean;
|
|
4
|
-
sfc?: boolean;
|
|
5
|
-
tsx?: boolean;
|
|
6
|
-
}
|
|
7
|
-
export declare function create(options: CreateCommandOptions): Promise<void>;
|
|
8
|
-
export {};
|
|
1
|
+
interface CreateCommandOptions {
|
|
2
|
+
name?: string;
|
|
3
|
+
locale?: boolean;
|
|
4
|
+
sfc?: boolean;
|
|
5
|
+
tsx?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function create(options: CreateCommandOptions): Promise<void>;
|
|
8
|
+
export {};
|
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
import ejs from 'ejs';
|
|
2
|
-
import fse from 'fs-extra';
|
|
3
|
-
import logger from '../shared/logger.js';
|
|
4
|
-
import { bigCamelize, camelize, kebabCase } from '@varlet/shared';
|
|
5
|
-
import inquirer from 'inquirer';
|
|
6
|
-
import { get } from 'lodash-es';
|
|
7
|
-
import { resolve } from 'path';
|
|
8
|
-
import { glob } from '../shared/fsUtils.js';
|
|
9
|
-
import { getVarletConfig } from '../config/varlet.config.js';
|
|
10
|
-
import { SRC_DIR, dirname } from '../shared/constant.js';
|
|
11
|
-
const { removeSync, readFileSync, copySync, pathExistsSync, writeFileSync } = fse;
|
|
12
|
-
const { prompt } = inquirer;
|
|
13
|
-
async function renderTemplates(componentFolder, componentFolderName, renderData) {
|
|
14
|
-
const templates = await glob(`${componentFolder}/**/*.ejs`);
|
|
15
|
-
templates.forEach((template) => {
|
|
16
|
-
const templateCode = readFileSync(template, { encoding: 'utf-8' });
|
|
17
|
-
const code = ejs.render(templateCode, renderData);
|
|
18
|
-
const file = template
|
|
19
|
-
.replace('[componentName]', camelize(componentFolderName))
|
|
20
|
-
.replace('[ComponentName]', bigCamelize(componentFolderName))
|
|
21
|
-
.replace('.ejs', '');
|
|
22
|
-
writeFileSync(file, code);
|
|
23
|
-
removeSync(template);
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
export async function create(options) {
|
|
27
|
-
logger.title('\nš¦š¦ Create a component ! \n');
|
|
28
|
-
const namespace = get(await getVarletConfig(), 'namespace');
|
|
29
|
-
const renderData = {
|
|
30
|
-
namespace,
|
|
31
|
-
bigCamelizeNamespace: bigCamelize(namespace),
|
|
32
|
-
kebabCaseName: 'component-name',
|
|
33
|
-
bigCamelizeName: 'ComponentName',
|
|
34
|
-
camelizeName: 'componentName',
|
|
35
|
-
style: 'vue',
|
|
36
|
-
};
|
|
37
|
-
const { name } = options.name
|
|
38
|
-
? options
|
|
39
|
-
: await prompt({
|
|
40
|
-
name: 'name',
|
|
41
|
-
message: 'Name of the component created: ',
|
|
42
|
-
default: renderData.kebabCaseName,
|
|
43
|
-
});
|
|
44
|
-
renderData.kebabCaseName = kebabCase(name);
|
|
45
|
-
renderData.camelizeName = camelize(name);
|
|
46
|
-
renderData.bigCamelizeName = bigCamelize(name);
|
|
47
|
-
const componentFolder = resolve(SRC_DIR, renderData.kebabCaseName);
|
|
48
|
-
const componentFolderName = renderData.kebabCaseName;
|
|
49
|
-
if (pathExistsSync(componentFolder)) {
|
|
50
|
-
logger.warning(`${componentFolderName} already exist and cannot be recreated...`);
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
const { locale } = options.locale
|
|
54
|
-
? options
|
|
55
|
-
: await prompt({
|
|
56
|
-
name: 'locale',
|
|
57
|
-
type: 'confirm',
|
|
58
|
-
message: 'Whether to use i18n?',
|
|
59
|
-
default: false,
|
|
60
|
-
});
|
|
61
|
-
renderData.locale = locale;
|
|
62
|
-
// Determine whether the parameter carries a component style
|
|
63
|
-
if (options.sfc || options.tsx) {
|
|
64
|
-
renderData.style = options.sfc ? 'vue' : 'tsx';
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
const { style } = await prompt({
|
|
68
|
-
name: 'style',
|
|
69
|
-
type: 'list',
|
|
70
|
-
message: 'Which style do you use to write your component ?',
|
|
71
|
-
choices: [
|
|
72
|
-
{ name: 'sfc', value: 'vue' },
|
|
73
|
-
{ name: 'tsx', value: 'tsx' },
|
|
74
|
-
],
|
|
75
|
-
default: 'vue',
|
|
76
|
-
});
|
|
77
|
-
renderData.style = style;
|
|
78
|
-
}
|
|
79
|
-
copySync(resolve(dirname, '../../../template/create'), componentFolder);
|
|
80
|
-
await renderTemplates(componentFolder, componentFolderName, renderData);
|
|
81
|
-
if (!renderData.locale) {
|
|
82
|
-
removeSync(resolve(componentFolder, '/example/locale'));
|
|
83
|
-
}
|
|
84
|
-
if (renderData.style !== 'vue') {
|
|
85
|
-
removeSync(resolve(componentFolder, `${renderData.bigCamelizeName}.vue`));
|
|
86
|
-
}
|
|
87
|
-
if (renderData.style !== 'tsx') {
|
|
88
|
-
removeSync(resolve(componentFolder, `${renderData.bigCamelizeName}.tsx`));
|
|
89
|
-
}
|
|
90
|
-
logger.success(`Create ${componentFolderName} component success!`);
|
|
91
|
-
}
|
|
1
|
+
import ejs from 'ejs';
|
|
2
|
+
import fse from 'fs-extra';
|
|
3
|
+
import logger from '../shared/logger.js';
|
|
4
|
+
import { bigCamelize, camelize, kebabCase } from '@varlet/shared';
|
|
5
|
+
import inquirer from 'inquirer';
|
|
6
|
+
import { get } from 'lodash-es';
|
|
7
|
+
import { resolve } from 'path';
|
|
8
|
+
import { glob } from '../shared/fsUtils.js';
|
|
9
|
+
import { getVarletConfig } from '../config/varlet.config.js';
|
|
10
|
+
import { SRC_DIR, dirname } from '../shared/constant.js';
|
|
11
|
+
const { removeSync, readFileSync, copySync, pathExistsSync, writeFileSync } = fse;
|
|
12
|
+
const { prompt } = inquirer;
|
|
13
|
+
async function renderTemplates(componentFolder, componentFolderName, renderData) {
|
|
14
|
+
const templates = await glob(`${componentFolder}/**/*.ejs`);
|
|
15
|
+
templates.forEach((template) => {
|
|
16
|
+
const templateCode = readFileSync(template, { encoding: 'utf-8' });
|
|
17
|
+
const code = ejs.render(templateCode, renderData);
|
|
18
|
+
const file = template
|
|
19
|
+
.replace('[componentName]', camelize(componentFolderName))
|
|
20
|
+
.replace('[ComponentName]', bigCamelize(componentFolderName))
|
|
21
|
+
.replace('.ejs', '');
|
|
22
|
+
writeFileSync(file, code);
|
|
23
|
+
removeSync(template);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export async function create(options) {
|
|
27
|
+
logger.title('\nš¦š¦ Create a component ! \n');
|
|
28
|
+
const namespace = get(await getVarletConfig(), 'namespace');
|
|
29
|
+
const renderData = {
|
|
30
|
+
namespace,
|
|
31
|
+
bigCamelizeNamespace: bigCamelize(namespace),
|
|
32
|
+
kebabCaseName: 'component-name',
|
|
33
|
+
bigCamelizeName: 'ComponentName',
|
|
34
|
+
camelizeName: 'componentName',
|
|
35
|
+
style: 'vue',
|
|
36
|
+
};
|
|
37
|
+
const { name } = options.name
|
|
38
|
+
? options
|
|
39
|
+
: await prompt({
|
|
40
|
+
name: 'name',
|
|
41
|
+
message: 'Name of the component created: ',
|
|
42
|
+
default: renderData.kebabCaseName,
|
|
43
|
+
});
|
|
44
|
+
renderData.kebabCaseName = kebabCase(name);
|
|
45
|
+
renderData.camelizeName = camelize(name);
|
|
46
|
+
renderData.bigCamelizeName = bigCamelize(name);
|
|
47
|
+
const componentFolder = resolve(SRC_DIR, renderData.kebabCaseName);
|
|
48
|
+
const componentFolderName = renderData.kebabCaseName;
|
|
49
|
+
if (pathExistsSync(componentFolder)) {
|
|
50
|
+
logger.warning(`${componentFolderName} already exist and cannot be recreated...`);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const { locale } = options.locale
|
|
54
|
+
? options
|
|
55
|
+
: await prompt({
|
|
56
|
+
name: 'locale',
|
|
57
|
+
type: 'confirm',
|
|
58
|
+
message: 'Whether to use i18n?',
|
|
59
|
+
default: false,
|
|
60
|
+
});
|
|
61
|
+
renderData.locale = locale;
|
|
62
|
+
// Determine whether the parameter carries a component style
|
|
63
|
+
if (options.sfc || options.tsx) {
|
|
64
|
+
renderData.style = options.sfc ? 'vue' : 'tsx';
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
const { style } = await prompt({
|
|
68
|
+
name: 'style',
|
|
69
|
+
type: 'list',
|
|
70
|
+
message: 'Which style do you use to write your component ?',
|
|
71
|
+
choices: [
|
|
72
|
+
{ name: 'sfc', value: 'vue' },
|
|
73
|
+
{ name: 'tsx', value: 'tsx' },
|
|
74
|
+
],
|
|
75
|
+
default: 'vue',
|
|
76
|
+
});
|
|
77
|
+
renderData.style = style;
|
|
78
|
+
}
|
|
79
|
+
copySync(resolve(dirname, '../../../template/create'), componentFolder);
|
|
80
|
+
await renderTemplates(componentFolder, componentFolderName, renderData);
|
|
81
|
+
if (!renderData.locale) {
|
|
82
|
+
removeSync(resolve(componentFolder, '/example/locale'));
|
|
83
|
+
}
|
|
84
|
+
if (renderData.style !== 'vue') {
|
|
85
|
+
removeSync(resolve(componentFolder, `${renderData.bigCamelizeName}.vue`));
|
|
86
|
+
}
|
|
87
|
+
if (renderData.style !== 'tsx') {
|
|
88
|
+
removeSync(resolve(componentFolder, `${renderData.bigCamelizeName}.tsx`));
|
|
89
|
+
}
|
|
90
|
+
logger.success(`Create ${componentFolderName} component success!`);
|
|
91
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
interface DevCommandOptions {
|
|
2
|
-
force?: boolean;
|
|
3
|
-
}
|
|
4
|
-
export declare function dev(options: DevCommandOptions): Promise<void>;
|
|
5
|
-
export {};
|
|
1
|
+
interface DevCommandOptions {
|
|
2
|
+
force?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare function dev(options: DevCommandOptions): Promise<void>;
|
|
5
|
+
export {};
|
package/lib/node/commands/dev.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import chokidar from 'chokidar';
|
|
2
|
-
import fse from 'fs-extra';
|
|
3
|
-
import logger from '../shared/logger.js';
|
|
4
|
-
import { createServer } from 'vite';
|
|
5
|
-
import { SRC_DIR, VARLET_CONFIG } from '../shared/constant.js';
|
|
6
|
-
import { buildSiteEntry } from '../compiler/compileSiteEntry.js';
|
|
7
|
-
import { getDevConfig } from '../config/vite.config.js';
|
|
8
|
-
import { getVarletConfig } from '../config/varlet.config.js';
|
|
9
|
-
import { merge } from 'lodash-es';
|
|
10
|
-
const { ensureDirSync, pathExistsSync } = fse;
|
|
11
|
-
let server;
|
|
12
|
-
let watcher;
|
|
13
|
-
async function startServer(force) {
|
|
14
|
-
const isRestart = Boolean(server);
|
|
15
|
-
logger.info(`${isRestart ? 'Res' : 'S'}tarting server...`);
|
|
16
|
-
// close all instance
|
|
17
|
-
server && (await server.close());
|
|
18
|
-
watcher && (await watcher.close());
|
|
19
|
-
// build all config
|
|
20
|
-
await buildSiteEntry();
|
|
21
|
-
const varletConfig = await getVarletConfig();
|
|
22
|
-
const devConfig = getDevConfig(varletConfig);
|
|
23
|
-
const inlineConfig = merge(devConfig, force ? { optimizeDeps: { force: true } } : {});
|
|
24
|
-
// create all instance
|
|
25
|
-
server = await createServer(inlineConfig);
|
|
26
|
-
await server.listen();
|
|
27
|
-
server.printUrls();
|
|
28
|
-
if (pathExistsSync(VARLET_CONFIG)) {
|
|
29
|
-
watcher = chokidar.watch(VARLET_CONFIG);
|
|
30
|
-
watcher.on('change', () => startServer(force));
|
|
31
|
-
}
|
|
32
|
-
logger.success(`\n${isRestart ? 'Res' : 'S'}tart successfully!!!`);
|
|
33
|
-
}
|
|
34
|
-
export async function dev(options) {
|
|
35
|
-
process.env.NODE_ENV = 'development';
|
|
36
|
-
ensureDirSync(SRC_DIR);
|
|
37
|
-
await startServer(options.force);
|
|
38
|
-
}
|
|
1
|
+
import chokidar from 'chokidar';
|
|
2
|
+
import fse from 'fs-extra';
|
|
3
|
+
import logger from '../shared/logger.js';
|
|
4
|
+
import { createServer } from 'vite';
|
|
5
|
+
import { SRC_DIR, VARLET_CONFIG } from '../shared/constant.js';
|
|
6
|
+
import { buildSiteEntry } from '../compiler/compileSiteEntry.js';
|
|
7
|
+
import { getDevConfig } from '../config/vite.config.js';
|
|
8
|
+
import { getVarletConfig } from '../config/varlet.config.js';
|
|
9
|
+
import { merge } from 'lodash-es';
|
|
10
|
+
const { ensureDirSync, pathExistsSync } = fse;
|
|
11
|
+
let server;
|
|
12
|
+
let watcher;
|
|
13
|
+
async function startServer(force) {
|
|
14
|
+
const isRestart = Boolean(server);
|
|
15
|
+
logger.info(`${isRestart ? 'Res' : 'S'}tarting server...`);
|
|
16
|
+
// close all instance
|
|
17
|
+
server && (await server.close());
|
|
18
|
+
watcher && (await watcher.close());
|
|
19
|
+
// build all config
|
|
20
|
+
await buildSiteEntry();
|
|
21
|
+
const varletConfig = await getVarletConfig();
|
|
22
|
+
const devConfig = getDevConfig(varletConfig);
|
|
23
|
+
const inlineConfig = merge(devConfig, force ? { optimizeDeps: { force: true } } : {});
|
|
24
|
+
// create all instance
|
|
25
|
+
server = await createServer(inlineConfig);
|
|
26
|
+
await server.listen();
|
|
27
|
+
server.printUrls();
|
|
28
|
+
if (pathExistsSync(VARLET_CONFIG)) {
|
|
29
|
+
watcher = chokidar.watch(VARLET_CONFIG);
|
|
30
|
+
watcher.on('change', () => startServer(force));
|
|
31
|
+
}
|
|
32
|
+
logger.success(`\n${isRestart ? 'Res' : 'S'}tart successfully!!!`);
|
|
33
|
+
}
|
|
34
|
+
export async function dev(options) {
|
|
35
|
+
process.env.NODE_ENV = 'development';
|
|
36
|
+
ensureDirSync(SRC_DIR);
|
|
37
|
+
await startServer(options.force);
|
|
38
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
interface GenCommandOptions {
|
|
2
|
-
name?: string;
|
|
3
|
-
i18n?: boolean;
|
|
4
|
-
sfc?: boolean;
|
|
5
|
-
tsx?: boolean;
|
|
6
|
-
}
|
|
7
|
-
export declare function gen(options: GenCommandOptions): Promise<void>;
|
|
8
|
-
export {};
|
|
1
|
+
interface GenCommandOptions {
|
|
2
|
+
name?: string;
|
|
3
|
+
i18n?: boolean;
|
|
4
|
+
sfc?: boolean;
|
|
5
|
+
tsx?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function gen(options: GenCommandOptions): Promise<void>;
|
|
8
|
+
export {};
|
package/lib/node/commands/gen.js
CHANGED
|
@@ -1,75 +1,76 @@
|
|
|
1
|
-
import logger from '../shared/logger.js';
|
|
2
|
-
import fse from 'fs-extra';
|
|
3
|
-
import inquirer from 'inquirer';
|
|
4
|
-
import { resolve } from 'path';
|
|
5
|
-
import { CLI_PACKAGE_JSON, CWD, GENERATORS_DIR } from '../shared/constant.js';
|
|
6
|
-
const { copy, pathExistsSync, readFileSync, writeFileSync, rename } = fse;
|
|
7
|
-
const { prompt } = inquirer;
|
|
8
|
-
function syncVersion(name) {
|
|
9
|
-
const file = resolve(CWD, name, 'package.json');
|
|
10
|
-
const pkg = JSON.parse(readFileSync(file, 'utf-8'));
|
|
11
|
-
const cliPkg = JSON.parse(readFileSync(CLI_PACKAGE_JSON, 'utf-8'));
|
|
12
|
-
Object.keys(pkg.devDependencies).forEach((key) => {
|
|
13
|
-
if (key.startsWith('@varlet')) {
|
|
14
|
-
pkg.devDependencies[key] = `^${cliPkg.version}`;
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
pkg.files = ['es', 'lib', 'umd', 'highlight', 'types'];
|
|
18
|
-
writeFileSync(file, JSON.stringify(pkg, null, 2));
|
|
19
|
-
}
|
|
20
|
-
export async function gen(options) {
|
|
21
|
-
logger.title('\nš¦š¦ Generate cli application ! \n');
|
|
22
|
-
const { name } = options.name
|
|
23
|
-
? options
|
|
24
|
-
: await prompt({
|
|
25
|
-
name: 'name',
|
|
26
|
-
message: 'Name of the generate application: ',
|
|
27
|
-
default: 'varlet-cli-app',
|
|
28
|
-
});
|
|
29
|
-
const dest = resolve(CWD, name);
|
|
30
|
-
if (pathExistsSync(dest)) {
|
|
31
|
-
logger.error(`${name} already exists and cannot be recreated...`);
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
let codeStyle;
|
|
35
|
-
// Determine whether the parameter carries a coding style
|
|
36
|
-
if (options.sfc || options.tsx) {
|
|
37
|
-
codeStyle = options.sfc ? 'sfc' : 'tsx';
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
const { style } = await prompt({
|
|
41
|
-
name: 'style',
|
|
42
|
-
type: 'list',
|
|
43
|
-
message: 'Please select your component library programming format',
|
|
44
|
-
choices: ['sfc', 'tsx'],
|
|
45
|
-
});
|
|
46
|
-
codeStyle = style;
|
|
47
|
-
}
|
|
48
|
-
const { i18n } = options.i18n
|
|
49
|
-
? options
|
|
50
|
-
: await prompt({
|
|
51
|
-
name: 'i18n',
|
|
52
|
-
type: 'confirm',
|
|
53
|
-
message: 'Whether to use i18n?',
|
|
54
|
-
default: false,
|
|
55
|
-
});
|
|
56
|
-
const dirName = i18n ? 'i18n' : 'default';
|
|
57
|
-
const base = resolve(GENERATORS_DIR, 'base');
|
|
58
|
-
const configBase = resolve(GENERATORS_DIR, 'config', dirName, 'base');
|
|
59
|
-
const code = resolve(GENERATORS_DIR, 'config', dirName, codeStyle);
|
|
60
|
-
await copy(base, dest);
|
|
61
|
-
await copy(configBase, dest);
|
|
62
|
-
await copy(code, dest);
|
|
63
|
-
await rename(resolve(dest, '_gitignore'), resolve(dest, '.gitignore'));
|
|
64
|
-
syncVersion(name);
|
|
65
|
-
logger.success('⨠Application generated successfully!');
|
|
1
|
+
import logger from '../shared/logger.js';
|
|
2
|
+
import fse from 'fs-extra';
|
|
3
|
+
import inquirer from 'inquirer';
|
|
4
|
+
import { resolve } from 'path';
|
|
5
|
+
import { CLI_PACKAGE_JSON, CWD, GENERATORS_DIR } from '../shared/constant.js';
|
|
6
|
+
const { copy, pathExistsSync, readFileSync, writeFileSync, rename } = fse;
|
|
7
|
+
const { prompt } = inquirer;
|
|
8
|
+
function syncVersion(name) {
|
|
9
|
+
const file = resolve(CWD, name, 'package.json');
|
|
10
|
+
const pkg = JSON.parse(readFileSync(file, 'utf-8'));
|
|
11
|
+
const cliPkg = JSON.parse(readFileSync(CLI_PACKAGE_JSON, 'utf-8'));
|
|
12
|
+
Object.keys(pkg.devDependencies).forEach((key) => {
|
|
13
|
+
if (key.startsWith('@varlet')) {
|
|
14
|
+
pkg.devDependencies[key] = `^${cliPkg.version}`;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
pkg.files = ['es', 'lib', 'umd', 'highlight', 'types'];
|
|
18
|
+
writeFileSync(file, JSON.stringify(pkg, null, 2));
|
|
19
|
+
}
|
|
20
|
+
export async function gen(options) {
|
|
21
|
+
logger.title('\nš¦š¦ Generate cli application ! \n');
|
|
22
|
+
const { name } = options.name
|
|
23
|
+
? options
|
|
24
|
+
: await prompt({
|
|
25
|
+
name: 'name',
|
|
26
|
+
message: 'Name of the generate application: ',
|
|
27
|
+
default: 'varlet-cli-app',
|
|
28
|
+
});
|
|
29
|
+
const dest = resolve(CWD, name);
|
|
30
|
+
if (pathExistsSync(dest)) {
|
|
31
|
+
logger.error(`${name} already exists and cannot be recreated...`);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
let codeStyle;
|
|
35
|
+
// Determine whether the parameter carries a coding style
|
|
36
|
+
if (options.sfc || options.tsx) {
|
|
37
|
+
codeStyle = options.sfc ? 'sfc' : 'tsx';
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
const { style } = await prompt({
|
|
41
|
+
name: 'style',
|
|
42
|
+
type: 'list',
|
|
43
|
+
message: 'Please select your component library programming format',
|
|
44
|
+
choices: ['sfc', 'tsx'],
|
|
45
|
+
});
|
|
46
|
+
codeStyle = style;
|
|
47
|
+
}
|
|
48
|
+
const { i18n } = options.i18n
|
|
49
|
+
? options
|
|
50
|
+
: await prompt({
|
|
51
|
+
name: 'i18n',
|
|
52
|
+
type: 'confirm',
|
|
53
|
+
message: 'Whether to use i18n?',
|
|
54
|
+
default: false,
|
|
55
|
+
});
|
|
56
|
+
const dirName = i18n ? 'i18n' : 'default';
|
|
57
|
+
const base = resolve(GENERATORS_DIR, 'base');
|
|
58
|
+
const configBase = resolve(GENERATORS_DIR, 'config', dirName, 'base');
|
|
59
|
+
const code = resolve(GENERATORS_DIR, 'config', dirName, codeStyle);
|
|
60
|
+
await copy(base, dest);
|
|
61
|
+
await copy(configBase, dest);
|
|
62
|
+
await copy(code, dest);
|
|
63
|
+
await rename(resolve(dest, '_gitignore'), resolve(dest, '.gitignore'));
|
|
64
|
+
syncVersion(name);
|
|
65
|
+
logger.success('⨠Application generated successfully!');
|
|
66
66
|
logger.info(`\
|
|
67
67
|
cd ${name}
|
|
68
|
+
git init (Generating .git folder to init git hooks)
|
|
68
69
|
pnpm install
|
|
69
|
-
pnpm dev`);
|
|
70
|
+
pnpm dev`);
|
|
70
71
|
logger.success(`\
|
|
71
72
|
=======================
|
|
72
73
|
Good luck have fun
|
|
73
74
|
=======================\
|
|
74
|
-
`);
|
|
75
|
-
}
|
|
75
|
+
`);
|
|
76
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
interface JestCommandOptions {
|
|
2
|
-
watch?: boolean;
|
|
3
|
-
watchAll?: boolean;
|
|
4
|
-
component?: string;
|
|
5
|
-
clearCache?: boolean;
|
|
6
|
-
}
|
|
7
|
-
export declare function jest(cmd: JestCommandOptions): Promise<void>;
|
|
8
|
-
export {};
|
|
1
|
+
interface JestCommandOptions {
|
|
2
|
+
watch?: boolean;
|
|
3
|
+
watchAll?: boolean;
|
|
4
|
+
component?: string;
|
|
5
|
+
clearCache?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function jest(cmd: JestCommandOptions): Promise<void>;
|
|
8
|
+
export {};
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import logger from '../shared/logger.js';
|
|
2
|
-
import jestModule from 'jest';
|
|
3
|
-
import { CWD, JEST_CONFIG } from '../shared/constant.js';
|
|
4
|
-
import { buildSiteEntry } from '../compiler/compileSiteEntry.js';
|
|
5
|
-
const { runCLI } = jestModule;
|
|
6
|
-
export async function jest(cmd) {
|
|
7
|
-
process.env.NODE_ENV = 'test';
|
|
8
|
-
const config = {
|
|
9
|
-
rootDir: CWD,
|
|
10
|
-
watch: cmd.watch,
|
|
11
|
-
watchAll: cmd.watchAll,
|
|
12
|
-
clearCache: cmd.clearCache,
|
|
13
|
-
config: JEST_CONFIG,
|
|
14
|
-
testRegex: cmd.component && `${cmd.component}/__tests__/.*.spec.[jt]s?$`,
|
|
15
|
-
};
|
|
16
|
-
await buildSiteEntry();
|
|
17
|
-
try {
|
|
18
|
-
const response = await runCLI(config, [CWD]);
|
|
19
|
-
if (!response.results.success && !cmd.watch) {
|
|
20
|
-
process.exit(1);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
catch (e) {
|
|
24
|
-
logger.error(e.toString());
|
|
25
|
-
process.exit(1);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
1
|
+
import logger from '../shared/logger.js';
|
|
2
|
+
import jestModule from 'jest';
|
|
3
|
+
import { CWD, JEST_CONFIG } from '../shared/constant.js';
|
|
4
|
+
import { buildSiteEntry } from '../compiler/compileSiteEntry.js';
|
|
5
|
+
const { runCLI } = jestModule;
|
|
6
|
+
export async function jest(cmd) {
|
|
7
|
+
process.env.NODE_ENV = 'test';
|
|
8
|
+
const config = {
|
|
9
|
+
rootDir: CWD,
|
|
10
|
+
watch: cmd.watch,
|
|
11
|
+
watchAll: cmd.watchAll,
|
|
12
|
+
clearCache: cmd.clearCache,
|
|
13
|
+
config: JEST_CONFIG,
|
|
14
|
+
testRegex: cmd.component && `${cmd.component}/__tests__/.*.spec.[jt]s?$`,
|
|
15
|
+
};
|
|
16
|
+
await buildSiteEntry();
|
|
17
|
+
try {
|
|
18
|
+
const response = await runCLI(config, [CWD]);
|
|
19
|
+
if (!response.results.success && !cmd.watch) {
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
logger.error(e.toString());
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
}
|