@farris/cli 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/commands/build-components.js +39 -0
- package/lib/commands/build-components.js.map +1 -0
- package/lib/commands/build-css.js +28 -0
- package/lib/commands/build-css.js.map +1 -0
- package/lib/commands/build-lib.js +28 -0
- package/lib/commands/build-lib.js.map +1 -0
- package/lib/commands/build.js +16 -0
- package/lib/commands/build.js.map +1 -0
- package/lib/commands/create-app.js +55 -0
- package/lib/commands/create-app.js.map +1 -0
- package/lib/commands/dev-serve.js +24 -0
- package/lib/commands/dev-serve.js.map +1 -0
- package/lib/commands/preview-serve.js +17 -0
- package/lib/commands/preview-serve.js.map +1 -0
- package/lib/common/constant.js +19 -0
- package/lib/common/constant.js.map +1 -0
- package/lib/common/generate-app.js +45 -0
- package/lib/common/generate-app.js.map +1 -0
- package/lib/common/get-dependencies.js +10 -0
- package/lib/common/get-dependencies.js.map +1 -0
- package/lib/common/get-farris-config.js +12 -0
- package/lib/common/get-farris-config.js.map +1 -0
- package/lib/common/get-version.js +7 -0
- package/lib/common/get-version.js.map +1 -0
- package/lib/common/get-vite-config.js +41 -0
- package/lib/common/get-vite-config.js.map +1 -0
- package/lib/config/vite-app.js +15 -0
- package/lib/config/vite-app.js.map +1 -0
- package/lib/config/vite-component.js +33 -0
- package/lib/config/vite-component.js.map +1 -0
- package/lib/config/vite-lib.js +28 -0
- package/lib/config/vite-lib.js.map +1 -0
- package/lib/index.js +66 -0
- package/lib/index.js.map +1 -0
- package/lib/plugins/create-component-style.js +45 -0
- package/lib/plugins/create-component-style.js.map +1 -0
- package/lib/plugins/create-package-json.js +34 -0
- package/lib/plugins/create-package-json.js.map +1 -0
- package/lib/plugins/dts.js +9 -0
- package/lib/plugins/dts.js.map +1 -0
- package/lib/plugins/html-system.js +12 -0
- package/lib/plugins/html-system.js.map +1 -0
- package/lib/plugins/replace.js +14 -0
- package/lib/plugins/replace.js.map +1 -0
- package/lib/plugins/systemjs-bundle.js +16 -0
- package/lib/plugins/systemjs-bundle.js.map +1 -0
- package/package.json +1 -1
@@ -0,0 +1,39 @@
|
|
1
|
+
import { readdirSync, lstatSync, existsSync } 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
|
+
const excludeComponents = ['property-panel', 'dynamic-resolver', 'dynamic-view'];
|
8
|
+
export async function buildComponents(options) {
|
9
|
+
process.env.BUILD_TYPE = 'components';
|
10
|
+
const components = readdirSync("./components").filter((name) => {
|
11
|
+
const componentDir = resolve(CWD, `./components`, name);
|
12
|
+
const isDir = lstatSync(componentDir).isDirectory();
|
13
|
+
return isDir && readdirSync(componentDir).includes("index.ts");
|
14
|
+
}).filter(name => !excludeComponents.includes(name));
|
15
|
+
const spinner = ora(`build components begin`).start();
|
16
|
+
components.forEach(async (component) => {
|
17
|
+
const entry = resolve(CWD, `./components/${component}/index.ts`);
|
18
|
+
const outDir = resolve(CWD, `./package/${component}`);
|
19
|
+
const config = {
|
20
|
+
publicDir: '',
|
21
|
+
build: {
|
22
|
+
lib: {
|
23
|
+
entry
|
24
|
+
},
|
25
|
+
outDir
|
26
|
+
}
|
27
|
+
};
|
28
|
+
spinner.text = `building ${component}`;
|
29
|
+
await buildCommon({ ...options, config, type: 'component' });
|
30
|
+
spinner.succeed(`build ${component} success`);
|
31
|
+
const cssEntry = `./components/${component}/src/${component}.scss`;
|
32
|
+
if (!existsSync(cssEntry)) {
|
33
|
+
return;
|
34
|
+
}
|
35
|
+
await buildCss({ ...options, entry: cssEntry, outfile: `./package/${component}/index.css` });
|
36
|
+
});
|
37
|
+
}
|
38
|
+
;
|
39
|
+
//# sourceMappingURL=build-components.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"build-components.js","sourceRoot":"","sources":["../../src/commands/build-components.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAA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GAAG;YACb,SAAS,EAAE,EAAE;YACb,KAAK,EAAE;gBACL,GAAG,EAAC;oBACF,KAAK;iBACN;gBACD,MAAM;aACP;SACF,CAAC;QAEF,OAAO,CAAC,IAAI,GAAG,YAAY,SAAS,EAAE,CAAC;QAEvC,MAAM,WAAW,CAAC,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAG,CAAC,CAAC;QAE9D,OAAO,CAAC,OAAO,CAAC,SAAS,SAAS,UAAU,CAAC,CAAC;QAE9C,MAAM,QAAQ,GAAG,gBAAgB,SAAS,QAAQ,SAAS,OAAO,CAAC;QACnE,IAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;YACxB,OAAO;SACR;QACD,MAAM,QAAQ,CAAC,EAAC,GAAG,OAAO,EAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,aAAa,SAAS,YAAY,EAAE,CAAC,CAAC;IAC7F,CAAC,CAAC,CAAC;AAEL,CAAC;AAAA,CAAC"}
|
@@ -0,0 +1,28 @@
|
|
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
|
+
const replaceUrl = (source, pathname, entry) => {
|
6
|
+
const basedir = path.dirname(pathname);
|
7
|
+
const entrydir = path.resolve(CWD, path.dirname(entry));
|
8
|
+
const relativedir = path.relative(entrydir, basedir);
|
9
|
+
const regExp = /(url\(['"]?)(\.\.?\/[^'")]+['"]?)(\))/g;
|
10
|
+
return source.replace(regExp, (substring, ...args) => `url(./${path.join(relativedir, args[1]).replaceAll('\\', '/')})`);
|
11
|
+
};
|
12
|
+
export async function buildCss(options) {
|
13
|
+
const { entry, outfile } = options;
|
14
|
+
await build({
|
15
|
+
entryPoints: [entry],
|
16
|
+
outfile,
|
17
|
+
bundle: true,
|
18
|
+
plugins: [sassPlugin({
|
19
|
+
precompile(source, pathname) {
|
20
|
+
return replaceUrl(source, pathname, entry);
|
21
|
+
}
|
22
|
+
})],
|
23
|
+
loader: {
|
24
|
+
'.ttf': 'dataurl'
|
25
|
+
}
|
26
|
+
});
|
27
|
+
}
|
28
|
+
//# sourceMappingURL=build-css.js.map
|
@@ -0,0 +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;AAE5C,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,GAAG,OAAO,CAAC;IACnC,MAAM,KAAK,CAAC;QACV,WAAW,EAAE,CAAC,KAAK,CAAC;QACpB,OAAO;QACP,MAAM,EAAE,IAAI;QACZ,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;AACL,CAAC"}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import ora from 'ora';
|
2
|
+
import { buildCommon } from "./build.js";
|
3
|
+
import { generateTypes } from "../plugins/dts.js";
|
4
|
+
import { existsSync } from 'node:fs';
|
5
|
+
import { buildCss } from './build-css.js';
|
6
|
+
import { createPackageJson } from '../plugins/create-package-json.js';
|
7
|
+
export async function buildLib(options) {
|
8
|
+
process.env.BUILD_TYPE = 'lib';
|
9
|
+
const { dts = true, emitPackage } = options;
|
10
|
+
const config = {
|
11
|
+
publicDir: '',
|
12
|
+
plugins: [
|
13
|
+
dts && generateTypes("./components", "./package/types"),
|
14
|
+
emitPackage && createPackageJson()
|
15
|
+
]
|
16
|
+
};
|
17
|
+
const spinner = ora(`build lib begin`).start();
|
18
|
+
spinner.text = `building lib`;
|
19
|
+
const libConfig = await buildCommon({ ...options, config, type: 'lib' });
|
20
|
+
const { css } = libConfig.build;
|
21
|
+
if (existsSync(css.entry)) {
|
22
|
+
spinner.text = `building css`;
|
23
|
+
await buildCss({ entry: css.entry, outfile: css.outfile });
|
24
|
+
}
|
25
|
+
spinner.succeed(`build success`);
|
26
|
+
}
|
27
|
+
;
|
28
|
+
//# sourceMappingURL=build-lib.js.map
|
@@ -0,0 +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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
3
|
+
export async function buildCommon(options, loadFile = true) {
|
4
|
+
const { configFile, config = {}, type } = options;
|
5
|
+
if (!loadFile) {
|
6
|
+
await build(config);
|
7
|
+
return config;
|
8
|
+
}
|
9
|
+
const viteConfig = await loadConfigFromFile({ command: 'build', mode: 'production' }, configFile);
|
10
|
+
const defaultConfig = await getViteConfig(type);
|
11
|
+
const libConfig = mergeConfig(mergeConfig(defaultConfig, viteConfig ? viteConfig.config : {}), config);
|
12
|
+
await build(libConfig);
|
13
|
+
return libConfig;
|
14
|
+
}
|
15
|
+
;
|
16
|
+
//# sourceMappingURL=build.js.map
|
@@ -0,0 +1 @@
|
|
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;AAQ7D,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,OAA2B,EAAE,QAAQ,GAAG,IAAI;IAC5E,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IAElD,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,UAAU,CAAC,CAAC;IAEhG,MAAM,aAAa,GAAG,MAAM,aAAa,CAAC,IAAI,CAAC,CAAC;IAEhD,MAAM,SAAS,GAAE,WAAW,CAAC,WAAW,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;IAEtG,MAAM,KAAK,CAAC,SAAS,CAAC,CAAC;IAEvB,OAAO,SAAS,CAAC;AACnB,CAAC;AAAA,CAAC"}
|
@@ -0,0 +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
|
+
;
|
55
|
+
//# sourceMappingURL=create-app.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"create-app.js","sourceRoot":"","sources":["../../src/commands/create-app.ts"],"names":[],"mappings":"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E;YACtB,MAAM,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAC;YAC1B,OAAO,IAAI,KAAK,KAAK,CAAC;QACxB,CAAC;KACF;CACF,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,SAAS;IAC7B,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC;IAEzC,WAAW,CAAC,QAAQ,CAAC,CAAC;AACxB,CAAC;AAAA,CAAC"}
|
@@ -0,0 +1,24 @@
|
|
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({
|
7
|
+
configFile: false,
|
8
|
+
mode: 'dev',
|
9
|
+
define: {
|
10
|
+
__VUE_OPTIONS_API__: 'true',
|
11
|
+
__VUE_PROD_DEVTOOLS__: 'true',
|
12
|
+
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'true'
|
13
|
+
},
|
14
|
+
server: {
|
15
|
+
port,
|
16
|
+
host,
|
17
|
+
hmr: true
|
18
|
+
}
|
19
|
+
}, config);
|
20
|
+
const server = await createServer(devConfig);
|
21
|
+
await server.listen();
|
22
|
+
server.printUrls();
|
23
|
+
};
|
24
|
+
//# sourceMappingURL=dev-serve.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"dev-serve.js","sourceRoot":"","sources":["../../src/commands/dev-serve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAO7D,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAAE,OAAqB,EAAE,EAAE;IACtD,MAAM,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAE7C,MAAM,MAAM,GAAG,MAAM,aAAa,EAAE,CAAC;IAErC,MAAM,SAAS,GAAG,WAAW,CAAC;QAC5B,UAAU,EAAE,KAAK;QACjB,IAAI,EAAE,KAAK;QACX,MAAM,EAAE;YACN,mBAAmB,EAAE,MAAM;YAC3B,qBAAqB,EAAE,MAAM;YAC7B,uCAAuC,EAAE,MAAM;SAChD;QACD,MAAM,EAAE;YACN,IAAI;YACJ,IAAI;YACJ,GAAG,EAAE,IAAI;SACV;KACF,EAAE,MAAM,CAAC,CAAC;IAEX,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,SAAS,CAAC,CAAC;IAC7C,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC;IAEtB,MAAM,CAAC,SAAS,EAAE,CAAC;AACrB,CAAC,CAAC"}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { preview, mergeConfig } from 'vite';
|
2
|
+
import { getViteConfig } from '../common/get-vite-config.js';
|
3
|
+
export const previewServe = async (options) => {
|
4
|
+
const { port = 4137, host = true } = options;
|
5
|
+
const config = await getViteConfig();
|
6
|
+
const previewConfig = mergeConfig({
|
7
|
+
configFile: false,
|
8
|
+
preview: {
|
9
|
+
port,
|
10
|
+
host,
|
11
|
+
open: true
|
12
|
+
}
|
13
|
+
}, config);
|
14
|
+
const server = await preview(previewConfig);
|
15
|
+
server.printUrls();
|
16
|
+
};
|
17
|
+
//# sourceMappingURL=preview-serve.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"preview-serve.js","sourceRoot":"","sources":["../../src/commands/preview-serve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAO7D,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAAE,OAAuB,EAAE,EAAE;IAC5D,MAAM,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAE7C,MAAM,MAAM,GAAG,MAAM,aAAa,EAAE,CAAC;IACrC,MAAM,aAAa,GAAG,WAAW,CAAC;QAChC,UAAU,EAAE,KAAK;QACjB,OAAO,EAAE;YACP,IAAI;YACJ,IAAI;YACJ,IAAI,EAAE,IAAI;SACX;KACF,EAAE,MAAM,CAAC,CAAC;IAEX,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC;IAE5C,MAAM,CAAC,SAAS,EAAE,CAAC;AACrB,CAAC,CAAC"}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { existsSync } from 'node:fs';
|
2
|
+
import { fileURLToPath } from 'node:url';
|
3
|
+
import { join, dirname } from 'node:path';
|
4
|
+
function findRootDir(dir) {
|
5
|
+
if (existsSync(join(dir, 'farris.config.js'))) {
|
6
|
+
return dir;
|
7
|
+
}
|
8
|
+
const parentDir = dirname(dir);
|
9
|
+
if (dir === parentDir) {
|
10
|
+
return dir;
|
11
|
+
}
|
12
|
+
return findRootDir(parentDir);
|
13
|
+
}
|
14
|
+
export const getDirname = (url) => fileURLToPath(new URL('.', url));
|
15
|
+
// Root paths
|
16
|
+
export const CWD = process.cwd();
|
17
|
+
export const ROOT = findRootDir(CWD);
|
18
|
+
export const FAARIS_CONFIG_FILE = join(CWD, 'farris.config.mjs');
|
19
|
+
//# sourceMappingURL=constant.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"constant.js","sourceRoot":"","sources":["../../src/common/constant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE1C,SAAS,WAAW,CAAC,GAAW;IAC9B,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC,EAAE;QAC7C,OAAO,GAAG,CAAC;KACZ;IAED,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAC/B,IAAI,GAAG,KAAK,SAAS,EAAE;QACrB,OAAO,GAAG,CAAC;KACZ;IAED,OAAO,WAAW,CAAC,SAAS,CAAC,CAAC;AAChC,CAAC;AACD,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,GAAW,EAAC,EAAE,CAAC,aAAa,CAAC,IAAI,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAE3E,aAAa;AAEb,MAAM,CAAC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;AACjC,MAAM,CAAC,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;AACrC,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC,GAAG,EAAE,mBAAmB,CAAC,CAAC"}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import { resolve } from 'path';
|
2
|
+
import { createRequire } from "node:module";
|
3
|
+
import { CWD, getDirname } from './constant.js';
|
4
|
+
import { getVersion } from "./get-version.js";
|
5
|
+
const require = createRequire(import.meta.url);
|
6
|
+
const { copySync, readFileSync, writeFileSync } = require("fs-extra");
|
7
|
+
const Array2String = (arr) => {
|
8
|
+
return `[${arr.reduce((acc, cur, index) => {
|
9
|
+
acc = index === 1 ? "'" + acc + "'" : acc;
|
10
|
+
acc += `,'${cur}'`;
|
11
|
+
return acc;
|
12
|
+
})}]`;
|
13
|
+
};
|
14
|
+
const copyTemplate = (template, target) => {
|
15
|
+
const templatePath = resolve(getDirname(import.meta.url), '../../templates', template);
|
16
|
+
const targetPath = resolve(CWD, target);
|
17
|
+
console.log(templatePath, targetPath);
|
18
|
+
copySync(templatePath, targetPath);
|
19
|
+
};
|
20
|
+
const replaceContent = (path, args) => {
|
21
|
+
let content = readFileSync(path, 'utf-8');
|
22
|
+
Object.keys(args).forEach((key) => {
|
23
|
+
const regexp = new RegExp(`<%= ${key} %>`, 'g');
|
24
|
+
const value = Array.isArray(args[key]) ? Array2String(args[key]) : args[key];
|
25
|
+
content = content.replace(regexp, value);
|
26
|
+
});
|
27
|
+
writeFileSync(path, content);
|
28
|
+
};
|
29
|
+
export const generateApp = (options) => {
|
30
|
+
const { name, type, formats, format, platform } = options;
|
31
|
+
const template = type === 'lib' ? 'lib' : platform;
|
32
|
+
copyTemplate(template, name);
|
33
|
+
const replaceFiles = [
|
34
|
+
'package.json',
|
35
|
+
'farris.config.mjs',
|
36
|
+
'index.html'
|
37
|
+
];
|
38
|
+
const cliVersion = getVersion();
|
39
|
+
replaceFiles.forEach(replaceFile => {
|
40
|
+
replaceContent(resolve(CWD, name, replaceFile), { name, formats, format, platform, cliVersion });
|
41
|
+
});
|
42
|
+
console.log(`cd ${name}`);
|
43
|
+
console.log(`npm install or yarn`);
|
44
|
+
};
|
45
|
+
//# sourceMappingURL=generate-app.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"generate-app.js","sourceRoot":"","sources":["../../src/common/generate-app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtE,MAAM,YAAY,GAAG,CAAC,GAAU,EAAE,EAAE;IAClC,OAAO,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE;QACxC,GAAG,GAAG,KAAK,KA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F,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,OAA2B,EAAE,EAAE;IACzD,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAC1D,MAAM,QAAQ,GAAG,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC;IACnD,YAAY,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAE7B,MAAM,YAAY,GAAG;QACnB,cAAc;QACd,mBAAmB;QACnB,YAAY;KACb,CAAC;IAEF,MAAM,UAAU,GAAG,UAAU,EAAE,CAAC;IAChC,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;QACjC,cAAc,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,WAAW,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC;IACnG,CAAC,CAAC,CAAC;IACH,OAAO,CAAC,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;IAC1B,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;AACrC,CAAC,CAAC"}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { readFileSync } from "node:fs";
|
2
|
+
import { resolve } from 'node:path';
|
3
|
+
import { CWD } from "../common/constant.js";
|
4
|
+
export const getDependencies = () => {
|
5
|
+
const pkg = readFileSync(resolve(CWD, 'package.json'), 'utf-8');
|
6
|
+
const packageJson = JSON.parse(pkg);
|
7
|
+
const { dependencies, peerDependencies } = packageJson;
|
8
|
+
return [...Object.keys(dependencies || {}), ...Object.keys(peerDependencies || {})];
|
9
|
+
};
|
10
|
+
//# sourceMappingURL=get-dependencies.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"get-dependencies.js","sourceRoot":"","sources":["../../src/common/get-dependencies.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,eAAe,GAAG,GAAG,EAAE;IAClC,MAAM,GAAG,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC,CAAC;IAChE,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpC,MAAM,EAAE,YAAY,EAAE,gBAAgB,EAAE,GAAG,WAAW,CAAC;IAEvD,OAAO,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC,CAAC;AACtF,CAAC,CAAC"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { pathToFileURL } from 'node:url';
|
2
|
+
import { FAARIS_CONFIG_FILE } from './constant.js';
|
3
|
+
async function getFarrisConfigAsync() {
|
4
|
+
try {
|
5
|
+
return (await import(pathToFileURL(FAARIS_CONFIG_FILE).href)).default;
|
6
|
+
}
|
7
|
+
catch (err) {
|
8
|
+
return {};
|
9
|
+
}
|
10
|
+
}
|
11
|
+
export { getFarrisConfigAsync };
|
12
|
+
//# sourceMappingURL=get-farris-config.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"get-farris-config.js","sourceRoot":"","sources":["../../src/common/get-farris-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,KAAK,UAAU,oBAAoB;IACjC,IAAI;QACF,OAAO,CAAC,MAAM,MAAM,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;KACvE;IAAC,OAAO,GAAG,EAAE;QACZ,OAAO,EAAE,CAAC;KACX;AACH,CAAC;AAED,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
@@ -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"}
|
@@ -0,0 +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, 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,MA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EF,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
@@ -0,0 +1,15 @@
|
|
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"}
|
@@ -0,0 +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
|
+
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
ADDED
@@ -0,0 +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
|
+
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
|
package/lib/index.js.map
ADDED
@@ -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,O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EAAE,CAAC"}
|
@@ -0,0 +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
|
+
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,CAA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AAE,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":"A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ources":["../../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"}
|
@@ -0,0 +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
|
+
};
|
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"}
|
@@ -0,0 +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
|
+
;
|
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"}
|