@farris/cli 2.1.7 → 2.2.0-beta.1
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/bin/index.js +1 -1
- package/lib/commands/build-components.js +48 -39
- package/lib/commands/build-components.js.map +1 -1
- package/lib/commands/build-css.js +38 -38
- package/lib/commands/build-css.js.map +1 -1
- package/lib/commands/build-lib.js +25 -25
- package/lib/commands/build-lib.js.map +1 -1
- package/lib/commands/build.js +15 -14
- package/lib/commands/build.js.map +1 -1
- package/lib/commands/create-app.js +54 -54
- package/lib/commands/dev-serve.js +18 -18
- package/lib/commands/extract-i18n.js +74 -74
- package/lib/commands/extract-i18n.js.map +1 -1
- package/lib/commands/preview-serve.js +16 -16
- package/lib/common/component-file-name.js +4 -0
- package/lib/common/component-file-name.js.map +1 -0
- package/lib/common/constant.js +22 -64
- package/lib/common/constant.js.map +1 -1
- package/lib/common/generate-app.js +51 -44
- package/lib/common/generate-app.js.map +1 -1
- package/lib/common/get-dependencies.js +9 -9
- package/lib/common/get-farris-config.js +25 -11
- package/lib/common/get-farris-config.js.map +1 -1
- package/lib/common/get-version.js +6 -6
- package/lib/common/get-vite-config.js +49 -105
- package/lib/common/get-vite-config.js.map +1 -1
- package/lib/common/lib-package-exports.js +21 -0
- package/lib/common/lib-package-exports.js.map +1 -0
- package/lib/common/list-lib-components.js +24 -0
- package/lib/common/list-lib-components.js.map +1 -0
- package/lib/common/template-manifest.js +17 -0
- package/lib/common/template-manifest.js.map +1 -0
- package/lib/config/vite-app.js +13 -13
- package/lib/config/vite-common.js +20 -20
- package/lib/config/vite-common.js.map +1 -1
- package/lib/config/vite-component.js +32 -30
- package/lib/config/vite-component.js.map +1 -1
- package/lib/config/vite-lib.js +26 -26
- package/lib/index.js +87 -175
- package/lib/index.js.map +1 -1
- package/lib/plugins/create-component-style.js +44 -44
- package/lib/plugins/create-package-json.js +48 -33
- package/lib/plugins/create-package-json.js.map +1 -1
- package/lib/plugins/dts.js +8 -8
- package/lib/plugins/html-system.js +9 -9
- package/lib/plugins/replace.js +17 -17
- package/lib/plugins/systemjs-bundle.js +15 -15
- package/lib/plugins/systemjs-bundle.js.map +1 -1
- package/package.json +9 -11
- package/templates/lib/.changeset/README.md +1 -0
- package/templates/lib/.changeset/config.json +11 -0
- package/templates/lib/README.md +17 -0
- package/templates/lib/components/button/index.ts +7 -0
- package/templates/lib/components/button/src/button.scss +10 -0
- package/templates/lib/components/button/src/button.vue +12 -0
- package/templates/lib/components/common/with-install.ts +9 -0
- package/templates/lib/components/index.ts +10 -0
- package/templates/lib/farris.config.mjs +13 -0
- package/templates/lib/package.json +21 -0
- package/templates/lib/tsconfig.json +7 -0
- package/templates/mobile/.changeset/README.md +4 -0
- package/templates/mobile/.changeset/config.json +11 -0
- package/templates/mobile/package.json +4 -1
- package/templates/web/.changeset/README.md +4 -0
- package/templates/web/.changeset/config.json +11 -0
- package/templates/web/package.json +4 -1
- package/lib/commands/generate/api.js +0 -188
- package/lib/commands/generate/api.js.map +0 -1
- package/lib/commands/generate/common.js +0 -101
- package/lib/commands/generate/common.js.map +0 -1
- package/lib/commands/generate/component.js +0 -164
- package/lib/commands/generate/component.js.map +0 -1
- package/lib/commands/generate/view.js +0 -198
- package/lib/commands/generate/view.js.map +0 -1
- package/lib/commands/workspace/add-app.js +0 -181
- package/lib/commands/workspace/add-app.js.map +0 -1
- package/lib/commands/workspace/create.js +0 -380
- package/lib/commands/workspace/create.js.map +0 -1
- package/lib/commands/workspace/inspect.js +0 -31
- package/lib/commands/workspace/inspect.js.map +0 -1
- package/lib/commands/workspace/verify.js +0 -39
- package/lib/commands/workspace/verify.js.map +0 -1
- package/lib/common/output.js +0 -95
- package/lib/common/output.js.map +0 -1
- package/lib/common/safety.js +0 -172
- package/lib/common/safety.js.map +0 -1
- package/lib/common/template-renderer.js +0 -115
- package/lib/common/template-renderer.js.map +0 -1
- package/lib/common/transaction.js +0 -84
- package/lib/common/transaction.js.map +0 -1
- package/lib/common/verifier.js +0 -151
- package/lib/common/verifier.js.map +0 -1
- package/templates/workspace/app/farris.config.mjs +0 -13
- package/templates/workspace/app/index.html +0 -12
- package/templates/workspace/app/package.json +0 -22
- package/templates/workspace/app/src/App.tsx +0 -11
- package/templates/workspace/app/src/locales/index.ts +0 -5
- package/templates/workspace/app/src/locales/zh-CN.json +0 -1
- package/templates/workspace/app/src/main.ts +0 -12
- package/templates/workspace/app/src/router/index.ts +0 -16
- package/templates/workspace/app/src/styles/index.css +0 -0
- package/templates/workspace/app/src/styles/index.scss +0 -0
- package/templates/workspace/app/src/views/home/composables/use-home.ts +0 -7
- package/templates/workspace/app/src/views/home/home.component.tsx +0 -15
- package/templates/workspace/app/src/views/home/index.ts +0 -4
- package/templates/workspace/app/tsconfig.json +0 -21
- package/templates/workspace/root/README.md +0 -28
- package/templates/workspace/root/package.json +0 -13
- package/templates/workspace/root/pnpm-workspace.yaml +0 -12
package/bin/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
import '../lib/index.js';
|
|
@@ -1,40 +1,49 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { resolve } from
|
|
3
|
-
import ora from 'ora';
|
|
4
|
-
import { buildCommon } from
|
|
5
|
-
import { buildCss } from
|
|
6
|
-
import { CWD } from
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
;
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import ora from 'ora';
|
|
4
|
+
import { buildCommon } from './build.js';
|
|
5
|
+
import { buildCss } from './build-css.js';
|
|
6
|
+
import { CWD } from '../common/constant.js';
|
|
7
|
+
import { getFarrisConfigAsync } from '../common/get-farris-config.js';
|
|
8
|
+
import { listLibComponents } from '../common/list-lib-components.js';
|
|
9
|
+
export async function buildComponents(options) {
|
|
10
|
+
const farris = await getFarrisConfigAsync(options.configFile);
|
|
11
|
+
const names = listLibComponents(process.cwd(), farris.excludeComponents);
|
|
12
|
+
if (names.length === 0) {
|
|
13
|
+
throw new Error('未找到可构建的组件(components/*/index.ts)');
|
|
14
|
+
}
|
|
15
|
+
const componentOutDir = farris.componentOutDir || './package/components';
|
|
16
|
+
const outDir = farris.outDir || 'lib';
|
|
17
|
+
const entry = Object.fromEntries(names.map((name) => [name, resolve(CWD, 'components', name, 'index.ts')]));
|
|
18
|
+
const spinner = ora('build components begin').start();
|
|
19
|
+
spinner.text = 'building components';
|
|
20
|
+
await buildCommon({
|
|
21
|
+
...options,
|
|
22
|
+
type: 'component',
|
|
23
|
+
config: {
|
|
24
|
+
publicDir: '',
|
|
25
|
+
build: {
|
|
26
|
+
emptyOutDir: false,
|
|
27
|
+
lib: { entry },
|
|
28
|
+
outDir: resolve(CWD, componentOutDir)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
const cssFiles = [];
|
|
33
|
+
for (const name of names) {
|
|
34
|
+
const scss = resolve(CWD, 'components', name, 'src', `${name}.scss`);
|
|
35
|
+
if (!existsSync(scss)) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const outfile = resolve(CWD, componentOutDir, name, 'index.css');
|
|
39
|
+
await buildCss({ ...options, entry: scss, outfile, showSpinner: false });
|
|
40
|
+
cssFiles.push(outfile);
|
|
41
|
+
}
|
|
42
|
+
if (cssFiles.length > 0) {
|
|
43
|
+
const aggregateDir = resolve(CWD, outDir);
|
|
44
|
+
mkdirSync(aggregateDir, { recursive: true });
|
|
45
|
+
writeFileSync(resolve(aggregateDir, 'index.css'), cssFiles.map((file) => readFileSync(file, 'utf-8')).join('\n'));
|
|
46
|
+
}
|
|
47
|
+
spinner.succeed('build components success');
|
|
48
|
+
}
|
|
40
49
|
//# sourceMappingURL=build-components.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-components.js","sourceRoot":"","sources":["../../src/commands/build-components.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"build-components.js","sourceRoot":"","sources":["../../src/commands/build-components.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAsB,WAAW,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,OAA2B;IAC/D,MAAM,MAAM,GAAG,MAAM,oBAAoB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC9D,MAAM,KAAK,GAAG,iBAAiB,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,iBAAiB,CAAC,CAAC;IACzE,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QACtB,MAAM,IAAI,KAAK,CAAC,kCAAk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AC,OAAO,CAAC,CAAC;KACxB;IAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;QACvB,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAC1C,SAAS,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC7C,aAAa,CACX,OAAO,CAAC,YAAY,EAAE,WAAW,CAAC,EAClC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAC/D,CAAC;KACH;IAED,OAAO,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { build } from "esbuild";
|
|
2
|
-
import { sassPlugin } from 'esbuild-sass-plugin';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import { CWD } from "../common/constant.js";
|
|
5
|
-
import ora from "ora";
|
|
6
|
-
const replaceUrl = (source, pathname, entry) => {
|
|
7
|
-
const basedir = path.dirname(pathname);
|
|
8
|
-
const entrydir = path.resolve(CWD, path.dirname(entry));
|
|
9
|
-
const relativedir = path.relative(entrydir, basedir);
|
|
10
|
-
const regExp = /(url\(['"]?)(\.\.?\/[^'")]+['"]?)(\))/g;
|
|
11
|
-
return source.replace(regExp, (substring, ...args) => `url(./${path.join(relativedir, args[1]).replaceAll('\\', '/')})`);
|
|
12
|
-
};
|
|
13
|
-
export async function buildCss(options) {
|
|
14
|
-
const { entry, outfile, minify = false, showSpinner = true } = options;
|
|
15
|
-
const spinner = ora(`build css begin`).start();
|
|
16
|
-
spinner.text = `building css`;
|
|
17
|
-
if (!showSpinner) {
|
|
18
|
-
spinner.stop();
|
|
19
|
-
}
|
|
20
|
-
await build({
|
|
21
|
-
entryPoints: [entry],
|
|
22
|
-
outfile,
|
|
23
|
-
minify,
|
|
24
|
-
bundle: true,
|
|
25
|
-
logLevel: 'error',
|
|
26
|
-
plugins: [sassPlugin({
|
|
27
|
-
precompile(source, pathname) {
|
|
28
|
-
return replaceUrl(source, pathname, entry);
|
|
29
|
-
}
|
|
30
|
-
})],
|
|
31
|
-
loader: {
|
|
32
|
-
'.ttf': 'dataurl'
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
if (showSpinner) {
|
|
36
|
-
spinner.succeed(`build css success`);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
1
|
+
import { build } from "esbuild";
|
|
2
|
+
import { sassPlugin } from 'esbuild-sass-plugin';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { CWD } from "../common/constant.js";
|
|
5
|
+
import ora from "ora";
|
|
6
|
+
const replaceUrl = (source, pathname, entry) => {
|
|
7
|
+
const basedir = path.dirname(pathname);
|
|
8
|
+
const entrydir = path.resolve(CWD, path.dirname(entry));
|
|
9
|
+
const relativedir = path.relative(entrydir, basedir);
|
|
10
|
+
const regExp = /(url\(['"]?)(\.\.?\/[^'")]+['"]?)(\))/g;
|
|
11
|
+
return source.replace(regExp, (substring, ...args) => `url(./${path.join(relativedir, args[1]).replaceAll('\\', '/')})`);
|
|
12
|
+
};
|
|
13
|
+
export async function buildCss(options) {
|
|
14
|
+
const { entry, outfile, minify = false, showSpinner = true } = options;
|
|
15
|
+
const spinner = ora(`build css begin`).start();
|
|
16
|
+
spinner.text = `building css`;
|
|
17
|
+
if (!showSpinner) {
|
|
18
|
+
spinner.stop();
|
|
19
|
+
}
|
|
20
|
+
await build({
|
|
21
|
+
entryPoints: [entry],
|
|
22
|
+
outfile,
|
|
23
|
+
minify,
|
|
24
|
+
bundle: true,
|
|
25
|
+
logLevel: 'error',
|
|
26
|
+
plugins: [sassPlugin({
|
|
27
|
+
precompile(source, pathname) {
|
|
28
|
+
return replaceUrl(source, pathname, entry);
|
|
29
|
+
}
|
|
30
|
+
})],
|
|
31
|
+
loader: {
|
|
32
|
+
'.ttf': 'dataurl'
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
if (showSpinner) {
|
|
36
|
+
spinner.succeed(`build css success`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
39
|
//# sourceMappingURL=build-css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-css.js","sourceRoot":"","sources":["../../src/commands/build-css.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,MAAM,UAAU,GAAG,CAAC,MAAc,EAAE,QAAgB,EAAE,KAAa,EAAC,EAAE;IACpE,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IACxD,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACrD,MAAM,MAAM,GAAG,wCAAwC,CAAC;IACxD,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,SAAS,EAAE,GAAG,IAAI,EAAC,EAAE,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;AAC1H,CAAC,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,OAAY;IACzC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,GAAG,KAAK,EAAE,WAAW,GAAG,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I,EAAE,GAAG,OAAO,CAAC;IAEvE,MAAM,OAAO,GAAG,GAAG,CAAC,iBAAiB,CAAC,CAAC,KAAK,EAAE,CAAC;IAC/C,OAAO,CAAC,IAAI,GAAG,cAAc,CAAC;IAE9B,IAAG,CAAC,WAAW,EAAE;QACf,OAAO,CAAC,IAAI,EAAE,CAAC;KAChB;IAGD,MAAM,KAAK,CAAC;QACV,WAAW,EAAE,CAAC,KAAK,CAAC;QACpB,OAAO;QACP,MAAM;QACN,MAAM,EAAE,IAAI;QACZ,QAAQ,EAAE,OAAO;QACjB,OAAO,EAAE,CAAC,UAAU,CAAC;gBACnB,UAAU,CAAC,MAAM,EAAE,QAAQ;oBACzB,OAAO,UAAU,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;gBAC7C,CAAC;aACF,CAAC,CAAC;QACH,MAAM,EAAE;YACN,MAAM,EAAE,SAAS;SAClB;KACF,CAAC,CAAC;IAEH,IAAG,WAAW,EAAE;QACd,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;KACtC;AACH,CAAC"}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import ora from 'ora';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import { createPackageJson } from '../plugins/create-package-json.js';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
spinner.succeed(`build lib success`);
|
|
24
|
-
}
|
|
25
|
-
;
|
|
1
|
+
import ora from 'ora';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { buildCommon } from "./build.js";
|
|
4
|
+
import { generateTypes } from "../plugins/dts.js";
|
|
5
|
+
import { createPackageJson } from '../plugins/create-package-json.js';
|
|
6
|
+
import { getFarrisConfigAsync } from '../common/get-farris-config.js';
|
|
7
|
+
import { CWD } from '../common/constant.js';
|
|
8
|
+
export async function buildLib(options) {
|
|
9
|
+
const { dts = true, emitPackage } = options;
|
|
10
|
+
const farrisConfig = await getFarrisConfigAsync(options.configFile);
|
|
11
|
+
const outDir = farrisConfig.outDir || 'lib';
|
|
12
|
+
const typesDir = resolve(CWD, outDir, 'types');
|
|
13
|
+
const config = {
|
|
14
|
+
publicDir: '',
|
|
15
|
+
plugins: [
|
|
16
|
+
dts && generateTypes('./components', typesDir),
|
|
17
|
+
emitPackage && createPackageJson()
|
|
18
|
+
]
|
|
19
|
+
};
|
|
20
|
+
const spinner = ora(`build lib begin`).start();
|
|
21
|
+
spinner.text = `building lib`;
|
|
22
|
+
await buildCommon({ ...options, config, type: 'lib' });
|
|
23
|
+
spinner.succeed(`build lib success`);
|
|
24
|
+
}
|
|
25
|
+
;
|
|
26
26
|
//# sourceMappingURL=build-lib.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-lib.js","sourceRoot":"","sources":["../../src/commands/build-lib.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,WAAW,EAAsB,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"build-lib.js","sourceRoot":"","sources":["../../src/commands/build-lib.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAsB,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAQ5C,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,OAAwB;IACrD,MAAM,EAAE,GAAG,GAAG,IAAI,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAC5C,MAAM,YAAY,GAAG,MAAM,oBAAoB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACpE,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,IAAI,KAAK,CAAC;IAC5C,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/C,MAAM,MAAM,GAAG;QACb,SAAS,EAAE,EAAE;QACb,OAAO,EAAE;YACP,GAAG,IAAI,aAAa,CAAC,cAAc,EAAE,QAAQ,CAAC;YAC9C,WAAW,IAAI,iBAAiB,EAAE;SACnC;KACF,CAAC;IACF,MAAM,OAAO,GAAG,GAAG,CAAC,iBAAiB,CAAC,CAAC,KAAK,EAAE,CAAC;IAE/C,OAAO,CAAC,IAAI,GAAG,cAAc,CAAC;IAE9B,MAAM,WAAW,CAAC,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAEvD,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;AACvC,CAAC;AAAA,CAAC"}
|
package/lib/commands/build.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { build, mergeConfig, loadConfigFromFile } from 'vite';
|
|
2
|
-
import { getViteConfig } from '../common/get-vite-config.js';
|
|
3
|
-
export async function buildCommon(options, loadFile = true) {
|
|
4
|
-
const { configFile, viteConfigFile, config = {}, type
|
|
5
|
-
if (!loadFile) {
|
|
6
|
-
await build(config);
|
|
7
|
-
return config;
|
|
8
|
-
}
|
|
9
|
-
const viteConfig = await loadConfigFromFile({ command: 'build', mode }, viteConfigFile);
|
|
10
|
-
const defaultConfig = await getViteConfig(type, configFile
|
|
11
|
-
const
|
|
12
|
-
await build(
|
|
13
|
-
return
|
|
14
|
-
}
|
|
1
|
+
import { build, mergeConfig, loadConfigFromFile } from 'vite';
|
|
2
|
+
import { getViteConfig } from '../common/get-vite-config.js';
|
|
3
|
+
export async function buildCommon(options, loadFile = true) {
|
|
4
|
+
const { configFile, viteConfigFile, config = {}, type } = options;
|
|
5
|
+
if (!loadFile) {
|
|
6
|
+
await build(config);
|
|
7
|
+
return config;
|
|
8
|
+
}
|
|
9
|
+
const viteConfig = await loadConfigFromFile({ command: 'build', mode: 'production' }, viteConfigFile);
|
|
10
|
+
const defaultConfig = await getViteConfig(type, configFile);
|
|
11
|
+
const libConfig = mergeConfig(mergeConfig(defaultConfig, viteConfigFile && viteConfig?.config ? viteConfig.config : {}), config);
|
|
12
|
+
await build(libConfig);
|
|
13
|
+
return libConfig;
|
|
14
|
+
}
|
|
15
|
+
;
|
|
15
16
|
//# sourceMappingURL=build.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAc,MAAM,MAAM,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAS7D,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,OAA2B,EAAE,QAAQ,GAAG,IAAI;IAC5E,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,GAAG,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IAElE,IAAG,CAAC,QAAQ,EAAE;QACZ,MAAM,KAAK,CAAC,MAAM,CAAC,CAAC;QACpB,OAAO,MAAM,CAAC;KACf;IAED,MAAM,UAAU,GAAG,MAAM,kBAAkB,CAAC,EAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAC,EAAE,cAAc,CAAC,CAAC;IAEpG,MAAM,aAAa,GAAG,MAAM,aAAa,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAE5D,MAAM,SAAS,GAAE,WAAW,CAAC,WAAW,CAAC,aAAa,EAAE,cAAc,IAAI,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;IAEhI,MAAM,KAAK,CAAC,SAAS,CAAC,CAAC;IAEvB,OAAO,SAAS,CAAC;AACnB,CAAC;AAAA,CAAC"}
|
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
import { generateApp } from "../common/generate-app.js";
|
|
2
|
-
import inquirer from "inquirer";
|
|
3
|
-
const prompt = inquirer.createPromptModule();
|
|
4
|
-
const questions = [
|
|
5
|
-
{
|
|
6
|
-
type: "input",
|
|
7
|
-
name: "name",
|
|
8
|
-
message: "What is your project name?",
|
|
9
|
-
default: "my-project",
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
type: "list",
|
|
13
|
-
name: "type",
|
|
14
|
-
message: "What type of project is this?",
|
|
15
|
-
choices: ["app", "lib"],
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
type: "list",
|
|
19
|
-
name: "platform",
|
|
20
|
-
message: "What platform of project is this?",
|
|
21
|
-
choices: ["web", "mobile"],
|
|
22
|
-
when: (response) => {
|
|
23
|
-
const { type } = response;
|
|
24
|
-
return type === 'app';
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
type: "checkbox",
|
|
29
|
-
name: "formats",
|
|
30
|
-
message: "What output format of project is this?",
|
|
31
|
-
choices: ["es", "umd", "systemjs"],
|
|
32
|
-
default: ["es", "umd"],
|
|
33
|
-
when: (response) => {
|
|
34
|
-
const { type } = response;
|
|
35
|
-
return type === 'lib';
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
type: "list",
|
|
40
|
-
name: "format",
|
|
41
|
-
message: "What output format of project is this?",
|
|
42
|
-
choices: ["es", "umd", "systemjs"],
|
|
43
|
-
default: ["es"],
|
|
44
|
-
when: (response) => {
|
|
45
|
-
const { type } = response;
|
|
46
|
-
return type === 'app';
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
];
|
|
50
|
-
export async function createApp() {
|
|
51
|
-
const response = await prompt(questions);
|
|
52
|
-
generateApp(response);
|
|
53
|
-
}
|
|
54
|
-
;
|
|
1
|
+
import { generateApp } from "../common/generate-app.js";
|
|
2
|
+
import inquirer from "inquirer";
|
|
3
|
+
const prompt = inquirer.createPromptModule();
|
|
4
|
+
const questions = [
|
|
5
|
+
{
|
|
6
|
+
type: "input",
|
|
7
|
+
name: "name",
|
|
8
|
+
message: "What is your project name?",
|
|
9
|
+
default: "my-project",
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
type: "list",
|
|
13
|
+
name: "type",
|
|
14
|
+
message: "What type of project is this?",
|
|
15
|
+
choices: ["app", "lib"],
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
type: "list",
|
|
19
|
+
name: "platform",
|
|
20
|
+
message: "What platform of project is this?",
|
|
21
|
+
choices: ["web", "mobile"],
|
|
22
|
+
when: (response) => {
|
|
23
|
+
const { type } = response;
|
|
24
|
+
return type === 'app';
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
type: "checkbox",
|
|
29
|
+
name: "formats",
|
|
30
|
+
message: "What output format of project is this?",
|
|
31
|
+
choices: ["es", "umd", "systemjs"],
|
|
32
|
+
default: ["es", "umd"],
|
|
33
|
+
when: (response) => {
|
|
34
|
+
const { type } = response;
|
|
35
|
+
return type === 'lib';
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
type: "list",
|
|
40
|
+
name: "format",
|
|
41
|
+
message: "What output format of project is this?",
|
|
42
|
+
choices: ["es", "umd", "systemjs"],
|
|
43
|
+
default: ["es"],
|
|
44
|
+
when: (response) => {
|
|
45
|
+
const { type } = response;
|
|
46
|
+
return type === 'app';
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
];
|
|
50
|
+
export async function createApp() {
|
|
51
|
+
const response = await prompt(questions);
|
|
52
|
+
generateApp(response);
|
|
53
|
+
}
|
|
54
|
+
;
|
|
55
55
|
//# sourceMappingURL=create-app.js.map
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { createServer, mergeConfig } from 'vite';
|
|
2
|
-
import { getViteConfig } from '../common/get-vite-config.js';
|
|
3
|
-
export const devServe = async (options) => {
|
|
4
|
-
const { port = 1337, host = true } = options;
|
|
5
|
-
const config = await getViteConfig();
|
|
6
|
-
const devConfig = mergeConfig(config, {
|
|
7
|
-
configFile: false,
|
|
8
|
-
mode: 'dev',
|
|
9
|
-
server: {
|
|
10
|
-
port,
|
|
11
|
-
host,
|
|
12
|
-
hmr: true
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
const server = await createServer(devConfig);
|
|
16
|
-
await server.listen();
|
|
17
|
-
server.printUrls();
|
|
18
|
-
};
|
|
1
|
+
import { createServer, mergeConfig } from 'vite';
|
|
2
|
+
import { getViteConfig } from '../common/get-vite-config.js';
|
|
3
|
+
export const devServe = async (options) => {
|
|
4
|
+
const { port = 1337, host = true } = options;
|
|
5
|
+
const config = await getViteConfig();
|
|
6
|
+
const devConfig = mergeConfig(config, {
|
|
7
|
+
configFile: false,
|
|
8
|
+
mode: 'dev',
|
|
9
|
+
server: {
|
|
10
|
+
port,
|
|
11
|
+
host,
|
|
12
|
+
hmr: true
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
const server = await createServer(devConfig);
|
|
16
|
+
await server.listen();
|
|
17
|
+
server.printUrls();
|
|
18
|
+
};
|
|
19
19
|
//# sourceMappingURL=dev-serve.js.map
|
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
import { writeFileSync, mkdirSync, existsSync, readFileSync } from 'fs';
|
|
2
|
-
import { join, basename, dirname, resolve } from 'path';
|
|
3
|
-
import { sync } from 'glob';
|
|
4
|
-
import { pathToFileURL } from 'url';
|
|
5
|
-
/**
|
|
6
|
-
* 抽取国际化资源到JSON文件
|
|
7
|
-
*/
|
|
8
|
-
async function loadConfig(configPath) {
|
|
9
|
-
const defaultConfigPath = resolve(process.cwd(), 'farris.i18n.mjs');
|
|
10
|
-
const finalPath = configPath || defaultConfigPath;
|
|
11
|
-
if (!existsSync(finalPath)) {
|
|
12
|
-
throw new Error(`配置文件不存在: ${finalPath}`);
|
|
13
|
-
}
|
|
14
|
-
const fileUrl = pathToFileURL(finalPath).href;
|
|
15
|
-
const config = (await import(fileUrl)).default;
|
|
16
|
-
return config;
|
|
17
|
-
}
|
|
18
|
-
async function extractByType(type, config, options) {
|
|
19
|
-
console.log(`正在提取 ${type} 资源...`);
|
|
20
|
-
const outputDir = options.outDir || config.outDir;
|
|
21
|
-
const localeMap = {};
|
|
22
|
-
// Process each include pattern
|
|
23
|
-
for (const pattern of config.include) {
|
|
24
|
-
const localeFiles = sync(pattern, {
|
|
25
|
-
cwd: process.cwd(),
|
|
26
|
-
absolute: true,
|
|
27
|
-
ignore: config.exclude
|
|
28
|
-
});
|
|
29
|
-
// Process each locale file
|
|
30
|
-
localeFiles.forEach(file => {
|
|
31
|
-
const componentName = basename(dirname(dirname(dirname(dirname(file)))));
|
|
32
|
-
const localeName = basename(file, '.json');
|
|
33
|
-
const content = readFileSync(file, 'utf8');
|
|
34
|
-
if (!content) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
const resources = JSON.parse(content);
|
|
38
|
-
if (!localeMap[localeName]) {
|
|
39
|
-
localeMap[localeName] = {};
|
|
40
|
-
}
|
|
41
|
-
// Add component translations under component namespace
|
|
42
|
-
Object.assign(localeMap[localeName], resources);
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
// Ensure output directory exists
|
|
46
|
-
if (!existsSync(outputDir)) {
|
|
47
|
-
mkdirSync(outputDir, { recursive: true });
|
|
48
|
-
}
|
|
49
|
-
// Write each locale to a separate file
|
|
50
|
-
Object.entries(localeMap).forEach(([locale, translations]) => {
|
|
51
|
-
const outputFile = join(outputDir, `${locale}.json`);
|
|
52
|
-
const content = config.minify
|
|
53
|
-
? JSON.stringify(translations)
|
|
54
|
-
: JSON.stringify(translations, null, 2);
|
|
55
|
-
writeFileSync(outputFile, content);
|
|
56
|
-
});
|
|
57
|
-
console.log(`${type} 资源提取完成!`);
|
|
58
|
-
}
|
|
59
|
-
export async function extractI18n(options = {}) {
|
|
60
|
-
console.log('正在抽取国际化资源...');
|
|
61
|
-
try {
|
|
62
|
-
const config = await loadConfig(options.configFile);
|
|
63
|
-
// 否则提取所有配置的类型
|
|
64
|
-
for (const [type, typeConfig] of Object.entries(config.extract)) {
|
|
65
|
-
if (typeConfig) {
|
|
66
|
-
await extractByType(type, typeConfig, options);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
console.error(error);
|
|
72
|
-
process.exit(1);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
1
|
+
import { writeFileSync, mkdirSync, existsSync, readFileSync } from 'fs';
|
|
2
|
+
import { join, basename, dirname, resolve } from 'path';
|
|
3
|
+
import { sync } from 'glob';
|
|
4
|
+
import { pathToFileURL } from 'url';
|
|
5
|
+
/**
|
|
6
|
+
* 抽取国际化资源到JSON文件
|
|
7
|
+
*/
|
|
8
|
+
async function loadConfig(configPath) {
|
|
9
|
+
const defaultConfigPath = resolve(process.cwd(), 'farris.i18n.mjs');
|
|
10
|
+
const finalPath = configPath || defaultConfigPath;
|
|
11
|
+
if (!existsSync(finalPath)) {
|
|
12
|
+
throw new Error(`配置文件不存在: ${finalPath}`);
|
|
13
|
+
}
|
|
14
|
+
const fileUrl = pathToFileURL(finalPath).href;
|
|
15
|
+
const config = (await import(fileUrl)).default;
|
|
16
|
+
return config;
|
|
17
|
+
}
|
|
18
|
+
async function extractByType(type, config, options) {
|
|
19
|
+
console.log(`正在提取 ${type} 资源...`);
|
|
20
|
+
const outputDir = options.outDir || config.outDir;
|
|
21
|
+
const localeMap = {};
|
|
22
|
+
// Process each include pattern
|
|
23
|
+
for (const pattern of config.include) {
|
|
24
|
+
const localeFiles = sync(pattern, {
|
|
25
|
+
cwd: process.cwd(),
|
|
26
|
+
absolute: true,
|
|
27
|
+
ignore: config.exclude
|
|
28
|
+
});
|
|
29
|
+
// Process each locale file
|
|
30
|
+
localeFiles.forEach(file => {
|
|
31
|
+
const componentName = basename(dirname(dirname(dirname(dirname(file)))));
|
|
32
|
+
const localeName = basename(file, '.json');
|
|
33
|
+
const content = readFileSync(file, 'utf8');
|
|
34
|
+
if (!content) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const resources = JSON.parse(content);
|
|
38
|
+
if (!localeMap[localeName]) {
|
|
39
|
+
localeMap[localeName] = {};
|
|
40
|
+
}
|
|
41
|
+
// Add component translations under component namespace
|
|
42
|
+
Object.assign(localeMap[localeName], resources);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
// Ensure output directory exists
|
|
46
|
+
if (!existsSync(outputDir)) {
|
|
47
|
+
mkdirSync(outputDir, { recursive: true });
|
|
48
|
+
}
|
|
49
|
+
// Write each locale to a separate file
|
|
50
|
+
Object.entries(localeMap).forEach(([locale, translations]) => {
|
|
51
|
+
const outputFile = join(outputDir, `${locale}.json`);
|
|
52
|
+
const content = config.minify
|
|
53
|
+
? JSON.stringify(translations)
|
|
54
|
+
: JSON.stringify(translations, null, 2);
|
|
55
|
+
writeFileSync(outputFile, content);
|
|
56
|
+
});
|
|
57
|
+
console.log(`${type} 资源提取完成!`);
|
|
58
|
+
}
|
|
59
|
+
export async function extractI18n(options = {}) {
|
|
60
|
+
console.log('正在抽取国际化资源...');
|
|
61
|
+
try {
|
|
62
|
+
const config = await loadConfig(options.configFile);
|
|
63
|
+
// 否则提取所有配置的类型
|
|
64
|
+
for (const [type, typeConfig] of Object.entries(config.extract)) {
|
|
65
|
+
if (typeConfig) {
|
|
66
|
+
await extractByType(type, typeConfig, options);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
console.error(error);
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
75
|
//# sourceMappingURL=extract-i18n.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-i18n.js","sourceRoot":"","sources":["../../src/commands/extract-i18n.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAsBpC;;GAEG;AACH,KAAK,UAAU,UAAU,CAAC,UAAmB;IACzC,MAAM,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,iBAAiB,CAAC,CAAC;IACpE,MAAM,SAAS,GAAG,UAAU,IAAI,iBAAiB,CAAC;IAElD,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE
|
|
1
|
+
{"version":3,"file":"extract-i18n.js","sourceRoot":"","sources":["../../src/commands/extract-i18n.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACxD,O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