@arkxio/ark-dev-utils 0.1.6 → 0.1.9

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/src/check.js CHANGED
@@ -1,102 +1,102 @@
1
- /*
2
- |--------------------------------------------------------------------------
3
- |
4
- | 此脚本在流水线上会被触发,用于校验组名是否和应用里的组名保持一致
5
- |
6
- |--------------------------------------------------------------------------
7
- */
8
- /** @typedef {import('../typings').ICheckOptions} ICheckOptions */
9
- import * as fs from 'fs';
10
- import * as os from 'os';
11
- import * as path from 'path';
12
- import cst from './configs/consts';
13
- import { verbose } from './inner-utils/index';
14
- import { pfstr } from './inner-utils/str';
15
-
16
- /**
17
- * @param {Record<string, any>} pkg - 用户模块的 package.json 文件
18
- * @param {ICheckOptions['fileFullPath'] | ICheckOptions} [subAppFilePathOrOptions] - 文件全路径名字,可带或不带后缀(.ts, .js)
19
- */
20
- export default function (pkg, subAppFilePathOrOptions) {
21
- let fileFullPath = path.join(__dirname, cst.DEFAULT_GUESS_SUB_APP_CONF_PATH);
22
- let checkEnv = true;
23
- if (subAppFilePathOrOptions) {
24
- if (typeof subAppFilePathOrOptions === 'string') {
25
- fileFullPath = subAppFilePathOrOptions;
26
- } else {
27
- fileFullPath = subAppFilePathOrOptions.fileFullPath;
28
- if (subAppFilePathOrOptions.checkEnv !== undefined) {
29
- checkEnv = subAppFilePathOrOptions.checkEnv;
30
- }
31
- }
32
- }
33
-
34
- /** 子应用组名 */
35
- let srcAppGroupName = '';
36
- let content = '';
37
- if (fileFullPath.endsWith('.js') || fileFullPath.endsWith('.ts')) {
38
- content = fs.readFileSync(fileFullPath);
39
- } else {
40
- const fileFullPathJs = `${fileFullPath}.js`;
41
- const fileFullPathTs = `${fileFullPath}.ts`;
42
- const isJsExist = fs.existsSync(fileFullPathJs);
43
- if (isJsExist) {
44
- verbose(`guess js subApp file: ${fileFullPathJs}`);
45
- content = fs.readFileSync(fileFullPathJs);
46
- } else {
47
- verbose(`guess ts subApp file: ${fileFullPathTs}`);
48
- const isTsExist = fs.existsSync(fileFullPathTs);
49
- if (isTsExist) {
50
- content = fs.readFileSync(fileFullPathTs);
51
- } else {
52
- throw new Error('no src/configs/subApp.(js|ts) file found');
53
- }
54
- }
55
- }
56
-
57
- const fileStr = content.toString();
58
- const strList = fileStr.split(os.EOL);
59
- for (const item of strList) {
60
- // export const HEL_APP_GROUP_NAME = 'your-app';
61
- // or
62
- // export const LIB_NAME = 'your-app';
63
- if (item.includes('export') && item.includes('const') && (item.includes('LIB_NAME') || item.includes('HEL_APP_GROUP_NAME'))) {
64
- const noBlankStr = item.replace(/ /gi, '');
65
- let [, appNameStr] = noBlankStr.split('=');
66
- appNameStr = appNameStr.replace(/'/gi, '');
67
- appNameStr = appNameStr.replace(/"/gi, '');
68
- appNameStr = appNameStr.replace(/;/gi, '');
69
- appNameStr = appNameStr.replace(/\r/gi, '');
70
- appNameStr = appNameStr.replace(/\n/gi, '');
71
- srcAppGroupName = appNameStr;
72
- break;
73
- }
74
- }
75
- if (!srcAppGroupName) {
76
- throw new Error(
77
- pfstr(`
78
- HEL_APP_GROUP_NAME or LIB_NAME not found in src/configs/subApp.(js|ts) file,
79
- your should expose it like below:
80
- export const HEL_APP_GROUP_NAME = 'your-app';
81
- or
82
- export const LIB_NAME = 'your-app';
83
- `),
84
- );
85
- }
86
-
87
- const pgkAppGroupName = pkg.appGroupName || pkg.name;
88
- if (pgkAppGroupName !== srcAppGroupName) {
89
- throw new Error(
90
- `package.json name [${pgkAppGroupName}] should be equal to src/configs/subApp LIB_NAME(or HEL_APP_GROUP_NAME) [${srcAppGroupName}]`,
91
- );
92
- }
93
-
94
- if (checkEnv) {
95
- // 以下常量由 ci&cd 系统注入(通常由流水线变量或 bash 脚本注入)
96
- const { HEL_APP_GROUP_NAME } = process.env;
97
-
98
- if (pgkAppGroupName !== HEL_APP_GROUP_NAME) {
99
- throw new Error(`package.json name [${pgkAppGroupName}] should be equal to pipeline var HEL_APP_GROUP_NAME [${HEL_APP_GROUP_NAME}]`);
100
- }
101
- }
102
- }
1
+ /*
2
+ |--------------------------------------------------------------------------
3
+ |
4
+ | 此脚本在流水线上会被触发,用于校验组名是否和应用里的组名保持一致
5
+ |
6
+ |--------------------------------------------------------------------------
7
+ */
8
+ /** @typedef {import('../typings').ICheckOptions} ICheckOptions */
9
+ import * as fs from 'fs';
10
+ import * as os from 'os';
11
+ import * as path from 'path';
12
+ import cst from './configs/consts';
13
+ import { verbose } from './inner-utils/index';
14
+ import { pfstr } from './inner-utils/str';
15
+
16
+ /**
17
+ * @param {Record<string, any>} pkg - 用户模块的 package.json 文件
18
+ * @param {ICheckOptions['fileFullPath'] | ICheckOptions} [subAppFilePathOrOptions] - 文件全路径名字,可带或不带后缀(.ts, .js)
19
+ */
20
+ export default function (pkg, subAppFilePathOrOptions) {
21
+ let fileFullPath = path.join(__dirname, cst.DEFAULT_GUESS_SUB_APP_CONF_PATH);
22
+ let checkEnv = true;
23
+ if (subAppFilePathOrOptions) {
24
+ if (typeof subAppFilePathOrOptions === 'string') {
25
+ fileFullPath = subAppFilePathOrOptions;
26
+ } else {
27
+ fileFullPath = subAppFilePathOrOptions.fileFullPath;
28
+ if (subAppFilePathOrOptions.checkEnv !== undefined) {
29
+ checkEnv = subAppFilePathOrOptions.checkEnv;
30
+ }
31
+ }
32
+ }
33
+
34
+ /** 子应用组名 */
35
+ let srcAppGroupName = '';
36
+ let content = '';
37
+ if (fileFullPath.endsWith('.js') || fileFullPath.endsWith('.ts')) {
38
+ content = fs.readFileSync(fileFullPath);
39
+ } else {
40
+ const fileFullPathJs = `${fileFullPath}.js`;
41
+ const fileFullPathTs = `${fileFullPath}.ts`;
42
+ const isJsExist = fs.existsSync(fileFullPathJs);
43
+ if (isJsExist) {
44
+ verbose(`guess js subApp file: ${fileFullPathJs}`);
45
+ content = fs.readFileSync(fileFullPathJs);
46
+ } else {
47
+ verbose(`guess ts subApp file: ${fileFullPathTs}`);
48
+ const isTsExist = fs.existsSync(fileFullPathTs);
49
+ if (isTsExist) {
50
+ content = fs.readFileSync(fileFullPathTs);
51
+ } else {
52
+ throw new Error('no src/configs/subApp.(js|ts) file found');
53
+ }
54
+ }
55
+ }
56
+
57
+ const fileStr = content.toString();
58
+ const strList = fileStr.split(os.EOL);
59
+ for (const item of strList) {
60
+ // export const HEL_APP_GROUP_NAME = 'your-app';
61
+ // or
62
+ // export const LIB_NAME = 'your-app';
63
+ if (item.includes('export') && item.includes('const') && (item.includes('LIB_NAME') || item.includes('HEL_APP_GROUP_NAME'))) {
64
+ const noBlankStr = item.replace(/ /gi, '');
65
+ let [, appNameStr] = noBlankStr.split('=');
66
+ appNameStr = appNameStr.replace(/'/gi, '');
67
+ appNameStr = appNameStr.replace(/"/gi, '');
68
+ appNameStr = appNameStr.replace(/;/gi, '');
69
+ appNameStr = appNameStr.replace(/\r/gi, '');
70
+ appNameStr = appNameStr.replace(/\n/gi, '');
71
+ srcAppGroupName = appNameStr;
72
+ break;
73
+ }
74
+ }
75
+ if (!srcAppGroupName) {
76
+ throw new Error(
77
+ pfstr(`
78
+ HEL_APP_GROUP_NAME or LIB_NAME not found in src/configs/subApp.(js|ts) file,
79
+ your should expose it like below:
80
+ export const HEL_APP_GROUP_NAME = 'your-app';
81
+ or
82
+ export const LIB_NAME = 'your-app';
83
+ `),
84
+ );
85
+ }
86
+
87
+ const pgkAppGroupName = pkg.appGroupName || pkg.name;
88
+ if (pgkAppGroupName !== srcAppGroupName) {
89
+ throw new Error(
90
+ `package.json name [${pgkAppGroupName}] should be equal to src/configs/subApp LIB_NAME(or HEL_APP_GROUP_NAME) [${srcAppGroupName}]`,
91
+ );
92
+ }
93
+
94
+ if (checkEnv) {
95
+ // 以下常量由 ci&cd 系统注入(通常由流水线变量或 bash 脚本注入)
96
+ const { HEL_APP_GROUP_NAME } = process.env;
97
+
98
+ if (pgkAppGroupName !== HEL_APP_GROUP_NAME) {
99
+ throw new Error(`package.json name [${pgkAppGroupName}] should be equal to pipeline var HEL_APP_GROUP_NAME [${HEL_APP_GROUP_NAME}]`);
100
+ }
101
+ }
102
+ }
@@ -1,24 +1,24 @@
1
- /**
2
- * @type {{
3
- * ARK_DIST_DIR: 'ark_dist',
4
- * ARK_PROXY_DIR: 'ark_proxy',
5
- * HEL_BUNDLE_DIR: 'ark_bundle',
6
- * DEFAULT_GUESS_SUB_APP_CONF_PATH:string,
7
- * DEFAULT_PLAT: 'unpkg',
8
- * DEFAULT_NPM_CDN_TYPE: 'unpkg',
9
- * DEFAULT_SEMVER_API: true,
10
- * DEFAULT_HTML_INDEX_NAME: 'index.html',
11
- * PLUGIN_VER:string,
12
- * }}
13
- */
14
- export default {
15
- ARK_DIST_DIR: 'ark_dist',
16
- ARK_PROXY_DIR: 'ark_proxy',
17
- HEL_BUNDLE_DIR: 'ark_bundle',
18
- DEFAULT_GUESS_SUB_APP_CONF_PATH: '../../../src/configs/subApp',
19
- DEFAULT_PLAT: 'unpkg',
20
- DEFAULT_NPM_CDN_TYPE: 'unpkg',
21
- DEFAULT_HTML_INDEX_NAME: 'index.html',
22
- DEFAULT_SEMVER_API: true,
23
- PLUGIN_VER: '4.3.20',
24
- };
1
+ /**
2
+ * @type {{
3
+ * ARK_DIST_DIR: 'ark_dist',
4
+ * ARK_PROXY_DIR: 'ark_proxy',
5
+ * HEL_BUNDLE_DIR: 'ark_bundle',
6
+ * DEFAULT_GUESS_SUB_APP_CONF_PATH:string,
7
+ * DEFAULT_PLAT: 'unpkg',
8
+ * DEFAULT_NPM_CDN_TYPE: 'unpkg',
9
+ * DEFAULT_SEMVER_API: true,
10
+ * DEFAULT_HTML_INDEX_NAME: 'index.html',
11
+ * PLUGIN_VER:string,
12
+ * }}
13
+ */
14
+ export default {
15
+ ARK_DIST_DIR: 'ark_dist',
16
+ ARK_PROXY_DIR: 'ark_proxy',
17
+ HEL_BUNDLE_DIR: 'ark_bundle',
18
+ DEFAULT_GUESS_SUB_APP_CONF_PATH: '../../../src/configs/subApp',
19
+ DEFAULT_PLAT: 'unpkg',
20
+ DEFAULT_NPM_CDN_TYPE: 'unpkg',
21
+ DEFAULT_HTML_INDEX_NAME: 'index.html',
22
+ DEFAULT_SEMVER_API: true,
23
+ PLUGIN_VER: '4.3.20',
24
+ };
@@ -1,25 +1,25 @@
1
- export default {
2
-
3
- vue: 'Vue',
4
- axios: 'axios',
5
- // vuex: 'Vuex',
6
- // 'vue-dim'
7
- pinia: 'Pinia',
8
- 'pinia-plugin-persistedstate': 'piniaPluginPersistedstate',
9
- 'vue-i18n': 'VueI18n',
10
- 'vue-router': 'VueRouter',
11
- 'element-plus': 'ElementPlus',
12
- '@arkxio/ark-micro-core': 'ArkMicroCore',
13
- '@arkxio/ark-lib-proxy': 'ArkLibProxy',
14
- '@arkxio/ark-micro': 'ArkMicro',
15
- '@arkxio/ark-plugin': 'ArkPlugin'
16
- // 'echarts': 'echarts',
17
- // 'tinymce': 'tinymce'
18
- // "loadjs": { //将vue依赖 "外部化",不打包进组件库
19
- // root: 'loadjs',
20
- // commonjs: 'loadjs',
21
- // commonjs2: 'loadjs',
22
- // amd: 'loadjs'
23
- // }
24
-
25
- }
1
+ export default {
2
+
3
+ vue: 'Vue',
4
+ axios: 'axios',
5
+ // vuex: 'Vuex',
6
+ // 'vue-dim'
7
+ pinia: 'Pinia',
8
+ 'pinia-plugin-persistedstate': 'piniaPluginPersistedstate',
9
+ 'vue-i18n': 'VueI18n',
10
+ 'vue-router': 'VueRouter',
11
+ 'element-plus': 'ElementPlus',
12
+ '@arkxio/ark-micro-core': 'ArkMicroCore',
13
+ '@arkxio/ark-lib-proxy': 'ArkLibProxy',
14
+ '@arkxio/ark-micro': 'ArkMicro',
15
+ '@arkxio/ark-plugin': 'ArkPlugin'
16
+ // 'echarts': 'echarts',
17
+ // 'tinymce': 'tinymce'
18
+ // "loadjs": { //将vue依赖 "外部化",不打包进组件库
19
+ // root: 'loadjs',
20
+ // commonjs: 'loadjs',
21
+ // commonjs2: 'loadjs',
22
+ // amd: 'loadjs'
23
+ // }
24
+
25
+ }
@@ -1,18 +1,18 @@
1
- export default {
2
- react: {
3
- react: 'React',
4
- 'react-dom': 'ReactDOM',
5
- 'react-is': 'ReactIs',
6
- },
7
- /** 历史原因,暂留 vue2 */
8
- vue2: {
9
- vue: 'Vue',
10
- },
11
- /** 历史原因,暂留 vue3 */
12
- vue3: {
13
- vue: 'Vue',
14
- },
15
- vue: {
16
- vue: 'Vue',
17
- },
18
- };
1
+ export default {
2
+ react: {
3
+ react: 'React',
4
+ 'react-dom': 'ReactDOM',
5
+ 'react-is': 'ReactIs',
6
+ },
7
+ /** 历史原因,暂留 vue2 */
8
+ vue2: {
9
+ vue: 'Vue',
10
+ },
11
+ /** 历史原因,暂留 vue3 */
12
+ vue3: {
13
+ vue: 'Vue',
14
+ },
15
+ vue: {
16
+ vue: 'Vue',
17
+ },
18
+ };
package/src/index.js CHANGED
@@ -1,33 +1,33 @@
1
- import * as baseUtils from './base-utils/index';
2
- import check from './check';
3
- import cst from './configs/consts';
4
- import extractArkMetaJson from './meta-extractor/index';
5
- import createLibSubApp from './sub-app/createLibSubApp';
6
- import createReactSubApp from './sub-app/createReactSubApp';
7
- import { createVueSubApp } from './sub-app/createVueSubApp';
8
- import ExternalsDefault from "./configs/externalsDefault";
9
- import ArkWebpackPlugin from "./ArkWebpackPlugin";
10
-
11
- export {
12
- check,
13
- cst,
14
- baseUtils,
15
- createReactSubApp,
16
- createVueSubApp,
17
- createLibSubApp,
18
- extractArkMetaJson,
19
- ExternalsDefault,
20
- ArkWebpackPlugin
21
- };
22
-
23
- export default {
24
- cst,
25
- check,
26
- baseUtils,
27
- createReactSubApp,
28
- createVueSubApp,
29
- createLibSubApp,
30
- extractArkMetaJson,
31
- ExternalsDefault,
32
- ArkWebpackPlugin
33
- };
1
+ import * as baseUtils from './base-utils/index';
2
+ import check from './check';
3
+ import cst from './configs/consts';
4
+ import extractArkMetaJson from './meta-extractor/index';
5
+ import createLibSubApp from './sub-app/createLibSubApp';
6
+ import createReactSubApp from './sub-app/createReactSubApp';
7
+ import { createVueSubApp } from './sub-app/createVueSubApp';
8
+ import ExternalsDefault from "./configs/externalsDefault";
9
+ import ArkWebpackPlugin from "./ArkWebpackPlugin";
10
+
11
+ export {
12
+ check,
13
+ cst,
14
+ baseUtils,
15
+ createReactSubApp,
16
+ createVueSubApp,
17
+ createLibSubApp,
18
+ extractArkMetaJson,
19
+ ExternalsDefault,
20
+ ArkWebpackPlugin
21
+ };
22
+
23
+ export default {
24
+ cst,
25
+ check,
26
+ baseUtils,
27
+ createReactSubApp,
28
+ createVueSubApp,
29
+ createLibSubApp,
30
+ extractArkMetaJson,
31
+ ExternalsDefault,
32
+ ArkWebpackPlugin
33
+ };
@@ -1,8 +1,8 @@
1
- /**
2
- *
3
- * @param {Array<string>} arr
4
- * @param {string} item
5
- */
6
- export function noDupPush(arr, item) {
7
- if (!arr.includes(item)) arr.push(item);
8
- }
1
+ /**
2
+ *
3
+ * @param {Array<string>} arr
4
+ * @param {string} item
5
+ */
6
+ export function noDupPush(arr, item) {
7
+ if (!arr.includes(item)) arr.push(item);
8
+ }