@farris/cli 2.0.0-beta.7 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. package/bin/index.js +0 -0
  2. package/lib/commands/build-components.js +39 -36
  3. package/lib/commands/build-components.js.map +1 -0
  4. package/lib/commands/build-css.js +28 -11
  5. package/lib/commands/build-css.js.map +1 -0
  6. package/lib/commands/build-lib.js +28 -16
  7. package/lib/commands/build-lib.js.map +1 -0
  8. package/lib/commands/build.js +16 -10
  9. package/lib/commands/build.js.map +1 -0
  10. package/lib/commands/create-app.js +55 -54
  11. package/lib/commands/create-app.js.map +1 -0
  12. package/lib/commands/dev-serve.js +24 -23
  13. package/lib/commands/dev-serve.js.map +1 -0
  14. package/lib/commands/preview-serve.js +17 -16
  15. package/lib/commands/preview-serve.js.map +1 -0
  16. package/lib/common/constant.js +19 -18
  17. package/lib/common/constant.js.map +1 -0
  18. package/lib/common/generate-app.js +45 -44
  19. package/lib/common/generate-app.js.map +1 -0
  20. package/lib/common/get-dependencies.js +10 -9
  21. package/lib/common/get-dependencies.js.map +1 -0
  22. package/lib/common/get-farris-config.js +12 -11
  23. package/lib/common/get-farris-config.js.map +1 -0
  24. package/lib/common/get-version.js +7 -6
  25. package/lib/common/get-version.js.map +1 -0
  26. package/lib/common/get-vite-config.js +41 -38
  27. package/lib/common/get-vite-config.js.map +1 -0
  28. package/lib/config/vite-app.js +15 -14
  29. package/lib/config/vite-app.js.map +1 -0
  30. package/lib/config/vite-component.js +33 -0
  31. package/lib/config/vite-component.js.map +1 -0
  32. package/lib/config/vite-lib.js +28 -35
  33. package/lib/config/vite-lib.js.map +1 -0
  34. package/lib/index.js +66 -54
  35. package/lib/index.js.map +1 -0
  36. package/lib/plugins/{gen-component-style.js → create-component-style.js} +45 -43
  37. package/lib/plugins/create-component-style.js.map +1 -0
  38. package/lib/plugins/create-package-json.js +34 -0
  39. package/lib/plugins/create-package-json.js.map +1 -0
  40. package/lib/plugins/dts.js +9 -8
  41. package/lib/plugins/dts.js.map +1 -0
  42. package/lib/plugins/html-system.js +12 -11
  43. package/lib/plugins/html-system.js.map +1 -0
  44. package/lib/plugins/replace.js +14 -13
  45. package/lib/plugins/replace.js.map +1 -0
  46. package/lib/plugins/systemjs-bundle.js +16 -0
  47. package/lib/plugins/systemjs-bundle.js.map +1 -0
  48. package/package.json +5 -3
  49. package/templates/mobile/farris.config.mjs +23 -23
  50. package/templates/{lib → web}/farris.config.mjs +23 -34
  51. package/templates/{lib → web}/package.json +4 -4
  52. package/templates/web/src/App.vue +80 -0
  53. package/templates/web/src/components/TheButton.vue +3 -0
  54. package/templates/{lib → web}/src/main.ts +3 -2
  55. package/templates/web/src/router/index.ts +23 -0
  56. package/templates/web/src/views/AboutView.vue +15 -0
  57. package/templates/web/src/views/HomeView.vue +9 -0
  58. package/templates/{lib → web}/tsconfig.json +5 -5
  59. package/templates/lib/packages/button/src/index.vue +0 -4
  60. package/templates/lib/packages/index.ts +0 -7
  61. package/templates/lib/src/App.vue +0 -5
  62. /package/templates/{lib → web}/.eslintrc.cjs +0 -0
  63. /package/templates/{lib → web}/.prettierrc.json +0 -0
  64. /package/templates/{lib → web}/index.html +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-version.js","sourceRoot":"","sources":["../../src/common/get-version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C,MAAM,WAAW,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAElD,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,EAAE;IAC7B,OAAO,WAAW,CAAC,OAAO,CAAC;AAC7B,CAAC,CAAC"}
@@ -1,38 +1,41 @@
1
- import { mergeConfig } from 'vite';
2
- import { getFarrisConfigAsync } from './get-farris-config.js';
3
- import { getDependencies } from '../common/get-dependencies.js';
4
- const formatFarrisConfig = (farrisConfig, type) => {
5
- const { lib, format, minify = true, externals = { include: [], exclude: [] }, externalDependencies, plugins, alias } = farrisConfig;
6
- const dependencies = externalDependencies ? getDependencies() : [];
7
- let external = externals.include ? [...externals.include, ...dependencies] : dependencies;
8
- external = external.filter(item => !externals.exclude?.includes(item));
9
- format && (process.env.FARRIS_FORMAT = format);
10
- const viteConfig = {
11
- build: {
12
- minify,
13
- lib: type === 'lib' ? lib : undefined,
14
- rollupOptions: {
15
- output: {
16
- format
17
- },
18
- external
19
- }
20
- },
21
- plugins,
22
- resolve: {
23
- alias
24
- }
25
- };
26
- return viteConfig;
27
- };
28
- const formatViteConfig = async (type) => {
29
- const { viteConfig = {}, ...farrisConfig } = await getFarrisConfigAsync();
30
- const customViteConfig = formatFarrisConfig(farrisConfig, type);
31
- return mergeConfig(customViteConfig, viteConfig);
32
- };
33
- const getViteConfig = async (type = 'app') => {
34
- const viteConfig = await formatViteConfig(type);
35
- const { default: defaultViteConfig } = await import(`../config/vite-${type}.js`);
36
- return mergeConfig(defaultViteConfig, viteConfig);
37
- };
38
- export { getViteConfig };
1
+ import { mergeConfig } from 'vite';
2
+ import { getFarrisConfigAsync } from './get-farris-config.js';
3
+ import { getDependencies } from '../common/get-dependencies.js';
4
+ const formatFarrisConfig = (farrisConfig, type) => {
5
+ const { lib, format, minify = true, outDir, externals = { include: [], exclude: [] }, externalDependencies, plugins, alias, css } = farrisConfig;
6
+ const dependencies = externalDependencies ? getDependencies() : [];
7
+ let external = externals.include ? [...externals.include, ...dependencies] : dependencies;
8
+ external = external.filter((item) => !externals.exclude?.includes(item));
9
+ format && (process.env.FARRIS_FORMAT = format);
10
+ const viteConfig = {
11
+ build: {
12
+ minify,
13
+ lib: type === 'lib' ? lib : undefined,
14
+ rollupOptions: {
15
+ output: {
16
+ format
17
+ },
18
+ external: externals.filter ? externals.filter(external) : external
19
+ },
20
+ outDir,
21
+ css
22
+ },
23
+ plugins,
24
+ resolve: {
25
+ alias
26
+ }
27
+ };
28
+ return viteConfig;
29
+ };
30
+ const formatViteConfig = async (type) => {
31
+ const { viteConfig = {}, ...farrisConfig } = await getFarrisConfigAsync();
32
+ const customViteConfig = formatFarrisConfig(farrisConfig, type);
33
+ return mergeConfig(customViteConfig, viteConfig);
34
+ };
35
+ const getViteConfig = async (type = 'app') => {
36
+ const viteConfig = await formatViteConfig(type);
37
+ const { default: defaultViteConfig } = await import(`../config/vite-${type}.js`);
38
+ return mergeConfig(defaultViteConfig, viteConfig);
39
+ };
40
+ export { getViteConfig };
41
+ //# sourceMappingURL=get-vite-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-vite-config.js","sourceRoot":"","sources":["../../src/common/get-vite-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8C,WAAW,EAAE,MAAM,MAAM,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAiBhE,MAAM,kBAAkB,GAAG,CAAC,YAA0B,EAAE,IAAY,EAAE,EAAE;IACtE,MAAM,EACJ,GAAG,EACH,MAAM,EACN,MAAM,GAAG,IAAI,EACb,MAAM,EACN,SAAS,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EACxC,oBAAoB,EACpB,OAAO,EACP,KAAK,EACL,GAAG,EACJ,GAAG,YAAY,CAAC;IAEjB,MAAM,YAAY,GAAG,oBAAoB,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAEnE,IAAI,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,OAAO,EAAE,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;IAE1F,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC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'@vitejs/plugin-vue-jsx';
3
- import { CWD } from '../common/constant.js';
4
- import { htmlSystemPlugin } from '../plugins/html-system.js';
5
- export default {
6
- root: CWD,
7
- base: './',
8
- // logLevel: 'silent',
9
- plugins: [
10
- vue(),
11
- vueJsx(),
12
- process.env.FARRIS_FORMAT === 'systemjs' && htmlSystemPlugin()
13
- ]
14
- };
1
+ import vue from '@vitejs/plugin-vue';
2
+ import vueJsx from '@vitejs/plugin-vue-jsx';
3
+ import { CWD } from '../common/constant.js';
4
+ import { htmlSystemPlugin } from '../plugins/html-system.js';
5
+ export default {
6
+ root: CWD,
7
+ base: './',
8
+ // logLevel: 'silent',
9
+ plugins: [
10
+ vue(),
11
+ vueJsx(),
12
+ process.env.FARRIS_FORMAT === 'systemjs' && htmlSystemPlugin()
13
+ ]
14
+ };
15
+ //# sourceMappingURL=vite-app.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-app.js","sourceRoot":"","sources":["../../src/config/vite-app.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,oBAAoB,CAAC;AACrC,OAAO,MAAM,MAAM,wBAAwB,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,eAAe;IACb,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,IAAI;IACV,sBAAsB;IACtB,OAAO,EAAE;QACP,GAAG,EAAE;QACL,MAAM,EAAE;QACR,OAAO,CAAC,GAAG,CAAC,aAAa,KAAK,UAAU,IAAI,gBAAgB,EAAE;KAC/D;CACF,CAAC"}
@@ -0,0 +1,33 @@
1
+ import vue from '@vitejs/plugin-vue';
2
+ import vueJsx from '@vitejs/plugin-vue-jsx';
3
+ import { CWD } from '../common/constant.js';
4
+ import { replace } from "../plugins/replace.js";
5
+ import { createComponentStyle } from "../plugins/create-component-style.js";
6
+ export default {
7
+ root: CWD,
8
+ base: './',
9
+ logLevel: 'silent',
10
+ plugins: [vue(), vueJsx(), createComponentStyle(), replace((format, args) => `..${args[1]}/index.${format}.js`)],
11
+ build: {
12
+ lib: {
13
+ fileName: "index",
14
+ formats: ["esm"],
15
+ },
16
+ rollupOptions: {
17
+ output: {
18
+ exports: "named",
19
+ globals: (id) => {
20
+ if (id.includes('@components')) {
21
+ const name = id.split('/').pop() || '';
22
+ return name.slice(0, 1).toUpperCase() + name.slice(1);
23
+ }
24
+ const map = {
25
+ vue: "Vue"
26
+ };
27
+ return map[id];
28
+ }
29
+ }
30
+ },
31
+ }
32
+ };
33
+ //# sourceMappingURL=vite-component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-component.js","sourceRoot":"","sources":["../../src/config/vite-component.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,oBAAoB,CAAC;AACrC,OAAO,MAAM,MAAM,wBAAwB,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAE5E,eAAe;IACb,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,IAAI;IACV,QAAQ,EAAE,QAAQ;IAClB,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,EAAE,oBAAoB,EAAE,EAAE,OAAO,CAAC,CAAC,MAAM,EAAE,IAAI,EAAC,EAAE,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,UAAU,MAAM,KAAK,CAAC,CAAC;IAC/G,KAAK,EAAC;QACJ,GAAG,EAAE;YACH,QAAQ,EAAE,OAAO;YACjB,OAAO,EAAE,CAAC,KAAK,CAAC;SACjB;QACD,aAAa,EAAE;YACb,MAAM,EAAE;gBACN,OAAO,EAAE,OAAO;gBAChB,OAAO,EAAE,CAAC,EAAU,EAAC,EAAE;oBACrB,IAAG,EAAE,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE;wBAC7B,MAAM,IAAI,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC;wBACvC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;qBACtD;oBACD,MAAM,GAAG,GAA2B;wBAClC,GAAG,EAAE,KAAK;qBACX,CAAC;oBACF,OAAO,GAAG,CAAC,EAAE,CAAC,CAAC;gBACjB,CAAC;aACF;SACF;KACF;CACF,CAAC"}
@@ -1,35 +1,28 @@
1
- import vue from '@vitejs/plugin-vue';
2
- import vueJsx from '@vitejs/plugin-vue-jsx';
3
- import { CWD } from '../common/constant.js';
4
- import { resolve } from "node:path";
5
- export default {
6
- root: CWD,
7
- base: './',
8
- logLevel: 'silent',
9
- plugins: [vue(), vueJsx()],
10
- build: {
11
- lib: {
12
- entry: resolve(CWD, `./src/main.ts`),
13
- fileName: "index",
14
- formats: ["es", "systemjs"],
15
- },
16
- outDir: resolve(CWD, `./lib`),
17
- rollupOptions: {
18
- external: [],
19
- output: {
20
- exports: "named",
21
- globals: (id) => {
22
- if (id.includes('@components')) {
23
- const name = id.split('/').pop() || '';
24
- return name.slice(0, 1).toUpperCase() + name.slice(1);
25
- }
26
- const map = {
27
- vue: "Vue",
28
- '@farris/mobile-ui-vue': 'FarrisVue'
29
- };
30
- return map[id];
31
- }
32
- }
33
- },
34
- }
35
- };
1
+ import vue from '@vitejs/plugin-vue';
2
+ import vueJsx from '@vitejs/plugin-vue-jsx';
3
+ import { CWD } from '../common/constant.js';
4
+ import { resolve } from "node:path";
5
+ import { systemjsBundle } from '../plugins/systemjs-bundle.js';
6
+ export default {
7
+ root: CWD,
8
+ base: './',
9
+ logLevel: 'silent',
10
+ plugins: [vue(), vueJsx(), systemjsBundle()],
11
+ build: {
12
+ lib: {
13
+ entry: resolve(CWD, `./src/main.ts`),
14
+ fileName: "index",
15
+ },
16
+ outDir: resolve(CWD, `./lib`),
17
+ rollupOptions: {
18
+ output: {
19
+ exports: "named",
20
+ globals: {
21
+ vue: "Vue",
22
+ '@farris/mobile-ui-vue': 'FarrisVue'
23
+ }
24
+ }
25
+ },
26
+ }
27
+ };
28
+ //# sourceMappingURL=vite-lib.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-lib.js","sourceRoot":"","sources":["../../src/config/vite-lib.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,oBAAoB,CAAC;AACrC,OAAO,MAAM,MAAM,wBAAwB,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,eAAe;IACb,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,IAAI;IACV,QAAQ,EAAE,QAAQ;IAClB,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,EAAE,cAAc,EAAE,CAAC;IAC5C,KAAK,EAAC;QACJ,GAAG,EAAE;YACH,KAAK,EAAE,OAAO,CAAC,GAAG,EAAE,eAAe,CAAC;YACpC,QAAQ,EAAE,OAAO;SAClB;QACD,MAAM,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC;QAC7B,aAAa,EAAE;YACb,MAAM,EAAE;gBACN,OAAO,EAAE,OAAO;gBAChB,OAAO,EAAE;oBACP,GAAG,EAAE,KAAK;oBACV,uBAAuB,EAAE,WAAW;iBACrC;aACF;SACF;KACF;CACF,CAAC"}
package/lib/index.js CHANGED
@@ -1,54 +1,66 @@
1
- #!/usr/bin/env node
2
- import { Command } from 'commander';
3
- import { getVersion } from "./common/get-version.js";
4
- const program = new Command();
5
- program.version(`@farris/cli ${getVersion()}`);
6
- program
7
- .command('build')
8
- .description('构建')
9
- .option('-c --configFile [configFile]', 'config file path')
10
- .action(async (options) => {
11
- const { buildCommon } = await import('./commands/build.js');
12
- return buildCommon(options);
13
- });
14
- program
15
- .command('build-lib')
16
- .description('构建')
17
- .option('-c --configFile [configFile]', 'config file path')
18
- .option('-d --dts', 'dts')
19
- .action(async (options) => {
20
- const { buildLib } = await import('./commands/build-lib.js');
21
- return buildLib(options);
22
- });
23
- program
24
- .command('build-components')
25
- .description('构建')
26
- .option('-c --configFile [configFile]', 'config file path')
27
- .action(async (options) => {
28
- const { buildComponents } = await import('./commands/build-components.js');
29
- return buildComponents(options);
30
- });
31
- program
32
- .command('create-app')
33
- .description('新建 App 模板')
34
- .action(async () => {
35
- const { createApp } = await import('./commands/create-app.js');
36
- return createApp();
37
- });
38
- program
39
- .command('dev')
40
- .description('创建 Dev Server')
41
- .option('-p --port [port]', 'Server Port')
42
- .action(async (options) => {
43
- const { devServe } = await import('./commands/dev-serve.js');
44
- return devServe(options);
45
- });
46
- program
47
- .command('preview')
48
- .description('创建 Preview Server')
49
- .option('-p --port [port]', 'Server Port')
50
- .action(async (options) => {
51
- const { previewServe } = await import('./commands/preview-serve.js');
52
- return previewServe(options);
53
- });
54
- program.parse();
1
+ #!/usr/bin/env node
2
+ import { Command } from 'commander';
3
+ import { getVersion } from "./common/get-version.js";
4
+ const program = new Command();
5
+ program.version(`@farris/cli ${getVersion()}`);
6
+ program
7
+ .command('build')
8
+ .description('构建')
9
+ .option('-c --configFile [configFile]', 'config file path')
10
+ .action(async (options) => {
11
+ const { buildCommon } = await import('./commands/build.js');
12
+ buildCommon(options);
13
+ });
14
+ program
15
+ .command('build-lib')
16
+ .description('构建')
17
+ .option('-c --configFile [configFile]', 'config file path')
18
+ .option('-f --format [format]', 'lib format')
19
+ .option('-d --dts', 'dts')
20
+ .option('-ep --emitPackage', 'createPackage')
21
+ .action(async (options) => {
22
+ const { buildLib } = await import('./commands/build-lib.js');
23
+ return buildLib(options);
24
+ });
25
+ program
26
+ .command('build-components')
27
+ .description('构建')
28
+ .option('-c --configFile [configFile]', 'config file path')
29
+ .action(async (options) => {
30
+ const { buildComponents } = await import('./commands/build-components.js');
31
+ return buildComponents(options);
32
+ });
33
+ program
34
+ .command('build-css')
35
+ .description('构建')
36
+ .option('-e --entry [entry]', 'entry file')
37
+ .option('-o --outfile [outfile]', 'outfile')
38
+ .action(async (options) => {
39
+ const { buildCss } = await import('./commands/build-css.js');
40
+ return buildCss(options);
41
+ });
42
+ program
43
+ .command('create-app')
44
+ .description('新建 App 模板')
45
+ .action(async () => {
46
+ const { createApp } = await import('./commands/create-app.js');
47
+ return createApp();
48
+ });
49
+ program
50
+ .command('dev')
51
+ .description('创建 Dev Server')
52
+ .option('-p --port [port]', 'Server Port')
53
+ .action(async (options) => {
54
+ const { devServe } = await import('./commands/dev-serve.js');
55
+ return devServe(options);
56
+ });
57
+ program
58
+ .command('preview')
59
+ .description('创建 Preview Server')
60
+ .option('-p --port [port]', 'Server Port')
61
+ .action(async (options) => {
62
+ const { previewServe } = await import('./commands/preview-serve.js');
63
+ return previewServe(options);
64
+ });
65
+ program.parse();
66
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO,CAAC,OAAO,CAAC,eAAe,UAAU,EAAE,EAAE,CAAC,CAAC;AAE/C,OAAO;KACJ,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,IAAI,CAAC;KACjB,MAAM,CAAC,8BAA8B,EAAE,kBAAkB,CAAC;KAC1D,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACxB,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC,CAA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AW,CAAC,WAAW,CAAC;KACxB,MAAM,CAAC,KAAK,IAAI,EAAE;IACjB,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,MAAM,CAAC,0BAA0B,CAAC,CAAC;IAC/D,OAAO,SAAS,EAAE,CAAC;AACrB,CAAC,CAAC,CAAC;AAEL,OAAO;KACJ,OAAO,CAAC,KAAK,CAAC;KACd,WAAW,CAAC,eAAe,CAAC;KAC5B,MAAM,CAAC,kBAAkB,EAAE,aAAa,CAAC;KACzC,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACxB,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,yBAAyB,CAAC,CAAC;IAC7D,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC;AAC3B,CAAC,CAAC,CAAC;AAEL,OAAO;KACJ,OAAO,CAAC,SAAS,CAAC;KAClB,WAAW,CAAC,mBAAmB,CAAC;KAChC,MAAM,CAAC,kBAAkB,EAAE,aAAa,CAAC;KACzC,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACxB,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,MAAM,CAAC,6BAA6B,CAAC,CAAC;IACrE,OAAO,YAAY,CAAC,OAAO,CAAC,CAAC;AAC/B,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,EAAE,CAAC"}
@@ -1,43 +1,45 @@
1
- const NotStyleComponents = ['designer-canvas', 'dynamic-view', 'dynamic-resolver', 'common'];
2
- const getComponentStyle = (imports) => {
3
- const components = imports
4
- .filter(path => {
5
- return path.startsWith('@components/') && !NotStyleComponents.find(notStylecomponent => path.includes(notStylecomponent));
6
- })
7
- .filter((item, index, array) => {
8
- return array.indexOf(item) === index;
9
- })
10
- .map(name => {
11
- const paths = name.split('/');
12
- return {
13
- name: paths[1],
14
- path: `../${paths[1]}/index.css`
15
- };
16
- });
17
- components.push({
18
- name: 'components',
19
- path: `./index.css`
20
- });
21
- const template = `${components.map(component => {
22
- const { path } = component;
23
- return `import '${path}';`;
24
- }).join('\n')}
25
- `;
26
- return template;
27
- };
28
- export function genComponentStyle() {
29
- return {
30
- name: 'farris-gen-component-style',
31
- renderChunk(code, chunk) {
32
- const { imports } = chunk;
33
- const template = getComponentStyle(imports);
34
- this.emitFile({
35
- type: 'asset',
36
- fileName: 'style.js',
37
- source: template
38
- });
39
- return code;
40
- }
41
- };
42
- }
43
- ;
1
+ const NotStyleComponents = ['designer-canvas', 'dynamic-view', 'dynamic-resolver', 'common'];
2
+ const getComponentStyle = (imports) => {
3
+ const components = imports
4
+ .filter(path => {
5
+ return path.startsWith('@components/') && !NotStyleComponents.find(notStylecomponent => path.includes(notStylecomponent));
6
+ })
7
+ .filter((item, index, array) => {
8
+ const targetIndex = array.filter(e => e !== item).findIndex(e => item.includes(e));
9
+ return targetIndex < 0;
10
+ })
11
+ .map(name => {
12
+ const paths = name.split('/');
13
+ return {
14
+ name: paths[1],
15
+ path: `../${paths[1]}/style.js`
16
+ };
17
+ });
18
+ components.push({
19
+ name: 'components',
20
+ path: `./index.css`
21
+ });
22
+ const template = `${components.map(component => {
23
+ const { path } = component;
24
+ return `import '${path}';`;
25
+ }).join('\n')}
26
+ `;
27
+ return template;
28
+ };
29
+ export function createComponentStyle() {
30
+ return {
31
+ name: 'farris-gen-component-style',
32
+ renderChunk(code, chunk) {
33
+ const { imports } = chunk;
34
+ const template = getComponentStyle(imports);
35
+ this.emitFile({
36
+ type: 'asset',
37
+ fileName: 'style.js',
38
+ source: template
39
+ });
40
+ return code;
41
+ }
42
+ };
43
+ }
44
+ ;
45
+ //# sourceMappingURL=create-component-style.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-component-style.js","sourceRoot":"","sources":["../../src/plugins/create-component-style.ts"],"names":[],"mappings":"AAAA,MAAM,kBAAkB,GAAG,CAAC,iBAAiB,EAAE,cAAc,EAAE,kBAAkB,EAAE,QAAQ,CAAC,CAAC;AAE7F,MAAM,iBAAiB,GAAG,CAAC,O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,4BAA4B;QAClC,WAAW,CAAC,IAAY,EAAE,KAAU;YAClC,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;YAE1B,MAAM,QAAQ,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;YAE5C,IAAI,CAAC,QAAQ,CAAC;gBACZ,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,UAAU;gBACpB,MAAM,EAAE,QAAQ;aACjB,CAAC,CAAC;YACH,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC;AAAA,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { resolve } from "node:path";
3
+ import { CWD } from "../common/constant.js";
4
+ export const createPackageJson = () => {
5
+ return {
6
+ name: 'create-package-json',
7
+ generateBundle() {
8
+ const pkg = readFileSync(resolve(CWD, 'package.json'), 'utf-8');
9
+ const packageJson = JSON.parse(pkg);
10
+ const result = {
11
+ name: '',
12
+ version: '',
13
+ private: false,
14
+ main: './index.umd.js',
15
+ module: './index.esm.js',
16
+ types: './types/index.d.ts',
17
+ style: './index.css',
18
+ };
19
+ const exclude = ['scripts', 'devDependencies', 'private'];
20
+ Object.keys(packageJson).forEach(key => {
21
+ if (exclude.includes(key)) {
22
+ return;
23
+ }
24
+ result[key] = packageJson[key];
25
+ });
26
+ this.emitFile({
27
+ type: 'asset',
28
+ fileName: 'package.json',
29
+ source: JSON.stringify(result, null, 2)
30
+ });
31
+ }
32
+ };
33
+ };
34
+ //# sourceMappingURL=create-package-json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-package-json.js","sourceRoot":"","sources":["../../src/plugins/create-package-json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAQ,EAAE;IACzC,OAAO;QACL,IAAI,EAAE,qBAAqB;QAC3B,cAAc;YACZ,MAAM,GAAG,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC,CAAC;YAChE,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACpC,MAAM,MAAM,GAAwB;gBAClC,IAAI,EAAE,EAAE;gBACR,OAAO,EAAE,EAAE;gBACX,OAAO,EAAE,KAAK;gBACd,IAAI,EAAE,gBAAgB;gBACtB,MAAM,EAAE,gBAAgB;gBACxB,KAAK,EAAE,oBAAoB;gBAC3B,KAAK,EAAE,aAAa;aACrB,CAAC;YACF,MAAM,OAAO,GAAG,CAAC,SAAS,EAAE,iBAAiB,EAAE,SAAS,CAAC,CAAC;YAC1D,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;gBACrC,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;oBACzB,OAAO;iBACR;gBACD,MAAM,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;YACjC,CAAC,CAAC,CAAC;YAEH,IAAI,CAAC,QAAQ,CAAC;gBACZ,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,cAAc;gBACxB,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;aACxC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC,CAAC"}
@@ -1,8 +1,9 @@
1
- import dts from "vite-plugin-dts";
2
- export function generateTypes(entry, outDir) {
3
- return dts({
4
- entryRoot: entry,
5
- outDir
6
- });
7
- }
8
- ;
1
+ import dts from "vite-plugin-dts";
2
+ export function generateTypes(entry, outDir) {
3
+ return dts({
4
+ entryRoot: entry,
5
+ outDir
6
+ });
7
+ }
8
+ ;
9
+ //# sourceMappingURL=dts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dts.js","sourceRoot":"","sources":["../../src/plugins/dts.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,iBAAiB,CAAC;AAElC,MAAM,UAAU,aAAa,CAAC,KAAa,EAAE,MAAc;IACzD,OAAO,GAAG,CAAC;QACT,SAAS,EAAE,KAAK;QAChB,MAAM;KACP,CAAC,CAAC;AACL,CAAC;AAAA,CAAC"}
@@ -1,11 +1,12 @@
1
- export const htmlSystemPlugin = () => {
2
- return {
3
- name: 'html-transform-system',
4
- transformIndexHtml(html) {
5
- const regexp = /<script.*type="module".*src="(.*?)"><\/script>/;
6
- return html.replace(regexp, (str, p1) => `
7
- <script src="https://cdn.bootcdn.net/ajax/libs/systemjs/6.15.1/system.js"></script>
8
- <script >System.import("${p1}");</script>`);
9
- }
10
- };
11
- };
1
+ export const htmlSystemPlugin = () => {
2
+ return {
3
+ name: 'html-transform-system',
4
+ transformIndexHtml(html) {
5
+ const regexp = /<script.*type="module".*src="(.*?)"><\/script>/;
6
+ return html.replace(regexp, (str, p1) => `
7
+ <script src="https://cdn.bootcdn.net/ajax/libs/systemjs/6.15.1/system.js"></script>
8
+ <script >System.import("${p1}");</script>`);
9
+ }
10
+ };
11
+ };
12
+ //# sourceMappingURL=html-system.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-system.js","sourceRoot":"","sources":["../../src/plugins/html-system.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACnC,OAAO;QACL,IAAI,EAAE,uBAAuB;QAC7B,kBAAkB,CAAC,IAAY;YAC7B,MAAM,MAAM,GAAG,gDAAgD,CAAC;YAChE,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,GAAW,EAAE,EAAU,EAAC,EAAE,CAAC;;8BAEhC,EAAE,cAAc,CAAC,CAAC;QAC5C,CAAC;KACF,CAAC;AACJ,CAAC,CAAC"}
@@ -1,13 +1,14 @@
1
- export function replace(path) {
2
- return {
3
- name: 'farris-replace',
4
- renderChunk(code, chunk) {
5
- const fileNames = chunk.fileName.split('.');
6
- const format = fileNames[fileNames.length - 2];
7
- return code.replace(/@components(\/\w+)/g, (...args) => {
8
- return path(format, args);
9
- });
10
- }
11
- };
12
- }
13
- ;
1
+ export function replace(path) {
2
+ return {
3
+ name: 'farris-replace',
4
+ renderChunk(code, chunk) {
5
+ const fileNames = chunk.fileName.split('.');
6
+ const format = fileNames[fileNames.length - 2];
7
+ return code.replace(/@components(\/\w+)/g, (...args) => {
8
+ return path(format, args);
9
+ });
10
+ }
11
+ };
12
+ }
13
+ ;
14
+ //# sourceMappingURL=replace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replace.js","sourceRoot":"","sources":["../../src/plugins/replace.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,OAAO,CAAC,IAAgD;IACtE,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,WAAW,CAAC,IAAY,EAAE,KAAU;YAClC,MAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC5C,MAAM,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,GAAC,CAAC,CAAC,CAAC;YAC7C,OAAO,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,CAAC,GAAG,IAAI,EAAC,EAAE;gBACpD,OAAO,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAC5B,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC;AAAA,CAAC"}
@@ -0,0 +1,16 @@
1
+ export function systemjsBundle() {
2
+ return {
3
+ name: 'systemjs-bundle',
4
+ outputOptions(options) {
5
+ if (options.format === 'systemjs') {
6
+ return {
7
+ ...options,
8
+ name: undefined
9
+ };
10
+ }
11
+ return options;
12
+ }
13
+ };
14
+ }
15
+ ;
16
+ //# sourceMappingURL=systemjs-bundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"systemjs-bundle.js","sourceRoot":"","sources":["../../src/plugins/systemjs-bundle.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,cAAc;IAC5B,OAAO;QACL,IAAI,EAAE,iBAAiB;QACvB,aAAa,CAAC,OAAY;YACxB,IAAG,OAAO,CAAC,MAAM,KAAK,UAAU,EAAE;gBAChC,OAAO;oBACL,GAAG,OAAO;oBACV,IAAI,EAAE,SAAS;iBAChB,CAAC;aACH;YACD,OAAO,OAAO,CAAC;QACjB,CAAC;KACF,CAAC;AACJ,CAAC;AAAA,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@farris/cli",
3
3
  "private": false,
4
- "version": "2.0.0-beta.7",
4
+ "version": "2.0.1",
5
5
  "type": "module",
6
6
  "typings": "lib/index.d.ts",
7
7
  "bin": {
@@ -18,17 +18,19 @@
18
18
  "templates",
19
19
  "bin.js"
20
20
  ],
21
+ "license": "MIT",
21
22
  "dependencies": {
22
23
  "@types/inquirer": "^9.0.7",
23
24
  "@vitejs/plugin-vue": "^4.0.0",
24
25
  "@vitejs/plugin-vue-jsx": "^3.0.0",
25
26
  "commander": "^9.4.0",
27
+ "esbuild": "^0.23.0",
26
28
  "esbuild-sass-plugin": "^3.3.1",
27
29
  "inquirer": "^9.3.0",
30
+ "ora": "^8.0.1",
28
31
  "typescript": "^4.6.4",
29
32
  "vite": "^4.4.1",
30
- "vite-plugin-dts": "^3.9.1",
31
- "vite-plugin-html": "^3.2.2"
33
+ "vite-plugin-dts": "^3.9.1"
32
34
  },
33
35
  "devDependencies": {
34
36
  "@types/inquirer": "^9.0.7",