neo-cmp-cli 1.8.6 → 1.8.8

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.
Files changed (127) hide show
  1. package/{src → bin}/index.js +18 -13
  2. package/bin/neo.js +1 -1
  3. package/dist/_virtual/_commonjsHelpers.js +12 -0
  4. package/dist/_virtual/array-set.js +7 -0
  5. package/dist/_virtual/base64-vlq.js +7 -0
  6. package/dist/_virtual/base64.js +7 -0
  7. package/dist/_virtual/binary-search.js +7 -0
  8. package/dist/_virtual/mapping-list.js +7 -0
  9. package/dist/_virtual/quick-sort.js +7 -0
  10. package/dist/_virtual/source-map-consumer.js +7 -0
  11. package/dist/_virtual/source-map-generator.js +7 -0
  12. package/dist/_virtual/source-map-support.js +7 -0
  13. package/dist/_virtual/source-map.js +7 -0
  14. package/dist/_virtual/source-node.js +7 -0
  15. package/dist/_virtual/typescript.js +7 -0
  16. package/dist/_virtual/util.js +7 -0
  17. package/dist/config/auth.config.js +43 -0
  18. package/dist/config/default.config.js +192 -0
  19. package/dist/config/index.js +26 -0
  20. package/dist/main.js +9 -0
  21. package/dist/main2.js +259 -0
  22. package/dist/module/inspect.js +63 -0
  23. package/dist/module/neoInit.js +75 -0
  24. package/dist/module/neoInitByCopy.js +83 -0
  25. package/dist/neo/neoLogin.js +590 -0
  26. package/dist/neo/neoRequire.js +123 -0
  27. package/dist/neo/neoService.js +898 -0
  28. package/dist/node_modules/buffer-from/index.js +86 -0
  29. package/dist/node_modules/source-map/lib/array-set.js +138 -0
  30. package/dist/node_modules/source-map/lib/base64-vlq.js +157 -0
  31. package/dist/node_modules/source-map/lib/base64.js +83 -0
  32. package/dist/node_modules/source-map/lib/binary-search.js +129 -0
  33. package/dist/node_modules/source-map/lib/mapping-list.js +96 -0
  34. package/dist/node_modules/source-map/lib/quick-sort.js +130 -0
  35. package/dist/node_modules/source-map/lib/source-map-consumer.js +1166 -0
  36. package/dist/node_modules/source-map/lib/source-map-generator.js +445 -0
  37. package/dist/node_modules/source-map/lib/source-node.js +431 -0
  38. package/dist/node_modules/source-map/lib/util.js +506 -0
  39. package/dist/node_modules/source-map/source-map.js +27 -0
  40. package/dist/node_modules/source-map-support/source-map-support.js +646 -0
  41. package/dist/node_modules/typescript/lib/typescript.js +174130 -0
  42. package/dist/oss/publish2oss.js +331 -0
  43. package/dist/plugins/AddNeoRequirePlugin.js +195 -0
  44. package/dist/utils/autoEntryRootDir.js +103 -0
  45. package/dist/utils/cmpUtils/createCmpByTemplate.js +82 -0
  46. package/dist/utils/cmpUtils/createCmpByZip.js +433 -0
  47. package/dist/utils/cmpUtils/createCommonModulesCode.js +139 -0
  48. package/dist/utils/cmpUtils/deleteCmp.js +81 -0
  49. package/dist/utils/cmpUtils/getCmpModelRegisterCode.js +47 -0
  50. package/dist/utils/cmpUtils/getCmpPreviewCode.js +60 -0
  51. package/dist/utils/cmpUtils/getCmpRegisterCode.js +47 -0
  52. package/dist/utils/cmpUtils/getCmpTypeByDir.js +59 -0
  53. package/dist/utils/cmpUtils/hasCmpTypeByDir.js +27 -0
  54. package/dist/utils/cmpUtils/previewCmp.js +75 -0
  55. package/dist/utils/cmpUtils/pullCmp.js +126 -0
  56. package/dist/utils/cmpUtils/pushCmp.js +254 -0
  57. package/dist/utils/common.js +125 -0
  58. package/dist/utils/configureNeoBuild.js +129 -0
  59. package/dist/utils/generateEntries.js +80 -0
  60. package/dist/utils/neoConfigInit.js +30 -0
  61. package/dist/utils/neoParams.js +26 -0
  62. package/dist/utils/pathUtils.js +40 -0
  63. package/dist/utils/projectNameValidator.js +90 -0
  64. package/dist/utils/projectUtils/createCmpProjectByTemplate.js +81 -0
  65. package/dist/utils/projectUtils/createCmpProjectZip.js +141 -0
  66. package/dist/utils/projectUtils/getEntries.js +99 -0
  67. package/dist/utils/projectUtils/getEntriesWithAutoRegister.js +129 -0
  68. package/dist/utils/projectUtils/hasNeoProject.js +34 -0
  69. package/dist/utils/projectUtils/openProject.js +117 -0
  70. package/dist/utils/projectUtils/updatePublishLog.js +47 -0
  71. package/dist/utils/replaceInFilesByMap.js +71 -0
  72. package/dist/utils/replaceInPackage.js +151 -0
  73. package/dist/utils/resetPackageVersion.js +132 -0
  74. package/package.json +5 -5
  75. package/test/demo.js +2 -4
  76. package/test/deprecate-versions.js +1 -1
  77. package/test/neo.config.js +1 -25
  78. package/src/config/auth.config.js +0 -27
  79. package/src/config/default.config.js +0 -176
  80. package/src/config/index.js +0 -9
  81. package/src/initData/defaultTemplate.html +0 -13
  82. package/src/initData/neo.config.js +0 -138
  83. package/src/main.js +0 -206
  84. package/src/module/inspect.js +0 -41
  85. package/src/module/neoInit.js +0 -55
  86. package/src/module/neoInitByCopy.js +0 -61
  87. package/src/neo/NeoUMDContent.js +0 -30
  88. package/src/neo/neoLogin.js +0 -565
  89. package/src/neo/neoRequire.js +0 -125
  90. package/src/neo/neoService.js +0 -874
  91. package/src/neo/webpack.mf.js +0 -60
  92. package/src/neo/wrapperContent.js +0 -16
  93. package/src/oss/publish2oss.js +0 -348
  94. package/src/plugins/AddNeoRequirePlugin-v1.js +0 -47
  95. package/src/plugins/AddNeoRequirePlugin.js +0 -179
  96. package/src/plugins/README.md +0 -109
  97. package/src/utils/autoEntryRootDir.js +0 -85
  98. package/src/utils/cmpUtils/createCmpByTemplate.js +0 -60
  99. package/src/utils/cmpUtils/createCmpByZip.js +0 -408
  100. package/src/utils/cmpUtils/createCommonModulesCode.js +0 -121
  101. package/src/utils/cmpUtils/deleteCmp.js +0 -63
  102. package/src/utils/cmpUtils/getCmpModelRegisterCode.js +0 -31
  103. package/src/utils/cmpUtils/getCmpPreviewCode.js +0 -43
  104. package/src/utils/cmpUtils/getCmpRegisterCode.js +0 -31
  105. package/src/utils/cmpUtils/getCmpTypeByDir.js +0 -41
  106. package/src/utils/cmpUtils/hasCmpTypeByDir.js +0 -11
  107. package/src/utils/cmpUtils/previewCmp.js +0 -55
  108. package/src/utils/cmpUtils/pullCmp.js +0 -104
  109. package/src/utils/cmpUtils/pushCmp.js +0 -230
  110. package/src/utils/common.js +0 -107
  111. package/src/utils/configureNeoBuild.js +0 -109
  112. package/src/utils/generateEntries.js +0 -63
  113. package/src/utils/neoConfigInit.js +0 -13
  114. package/src/utils/neoParams.js +0 -12
  115. package/src/utils/pathUtils.js +0 -23
  116. package/src/utils/projectNameValidator.js +0 -76
  117. package/src/utils/projectUtils/createCmpProjectByTemplate.js +0 -59
  118. package/src/utils/projectUtils/createCmpProjectZip.js +0 -120
  119. package/src/utils/projectUtils/getEntries.js +0 -80
  120. package/src/utils/projectUtils/getEntriesWithAutoRegister.js +0 -108
  121. package/src/utils/projectUtils/hasNeoProject.js +0 -17
  122. package/src/utils/projectUtils/openProject.js +0 -94
  123. package/src/utils/projectUtils/updatePublishLog.js +0 -30
  124. package/src/utils/replaceInFiles.js +0 -47
  125. package/src/utils/replaceInFilesByMap.js +0 -54
  126. package/src/utils/replaceInPackage.js +0 -134
  127. package/src/utils/resetPackageVersion.js +0 -115
@@ -0,0 +1,125 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const require$$0 = require('chalk');
6
+ const typescript = require('../node_modules/typescript/lib/typescript.js');
7
+ const neoParams = require('./neoParams.js');
8
+
9
+ var common;
10
+ var hasRequiredCommon;
11
+
12
+ function requireCommon () {
13
+ if (hasRequiredCommon) return common;
14
+ hasRequiredCommon = 1;
15
+ const chalk = require$$0;
16
+ const ts = typescript.__require();
17
+ const { consoleTag } = neoParams.__require();
18
+
19
+ /**
20
+ * 获取技术栈标识
21
+ * 目的:兼容用户非标准写法
22
+ * 0: React, 1: vue2, 2: jQuery, 3: vue3
23
+ */
24
+ function getFramework(_framework) {
25
+ let defaultFramework = 0; // 默认 React 技术栈
26
+ if (!_framework) {
27
+ return defaultFramework;
28
+ }
29
+ let curFramework = _framework.toLowerCase().trim();
30
+ switch (curFramework) {
31
+ case 'jquery':
32
+ case 'jq':
33
+ curFramework = 2;
34
+ break;
35
+ case 'vue2':
36
+ case 'vue 2':
37
+ case 'vue2.0':
38
+ case 'vue 2.0':
39
+ curFramework = 1;
40
+ break;
41
+ case 'vue':
42
+ case 'vue3':
43
+ case 'vue 3':
44
+ case 'vue3.0':
45
+ case 'vue 3.0':
46
+ curFramework = 3;
47
+ errorLog('暂不支持 vue3.0 技术栈。');
48
+ break;
49
+ case 'react-js':
50
+ errorLog('暂不支持 react-js 技术栈。');
51
+ curFramework = 0;
52
+ break;
53
+ case 'react':
54
+ case 'react-ts':
55
+ curFramework = 0;
56
+ break;
57
+ default:
58
+ curFramework = 0;
59
+ }
60
+ return curFramework;
61
+ }
62
+
63
+ // 输出红色字体的错误日志
64
+ function errorLog(message, spinner) {
65
+ const errorMessage = `${consoleTag} ${chalk.red(message)}`;
66
+ if (spinner) {
67
+ spinner.fail(errorMessage);
68
+ } else {
69
+ console.error(errorMessage);
70
+ }
71
+ }
72
+
73
+ // 输出黄色字体的警告日志
74
+ function warningLog(message, spinner) {
75
+ const warningMessage = `${consoleTag} ${chalk.yellow(message)}`;
76
+ if (spinner) {
77
+ spinner.warn(warningMessage);
78
+ } else {
79
+ console.warn(warningMessage);
80
+ }
81
+ }
82
+
83
+ // 输出绿色字体的成功日志
84
+ function successLog(message, spinner) {
85
+ const successMessage = `${consoleTag} ${chalk.green(message)}`;
86
+ if (spinner) {
87
+ spinner.succeed(successMessage);
88
+ } else {
89
+ console.log(successMessage);
90
+ }
91
+ }
92
+
93
+ /**
94
+ * 使用 TypeScript 官方 API 解析 tsconfig.json(推荐)
95
+ * 需要安装: npm install typescript --save-dev
96
+ * 优点: 官方支持,能正确处理 extends、注释等所有特性
97
+ */
98
+ function parseTsConfigWithTypeScript(configPath) {
99
+ try {
100
+ const configFile = ts.readConfigFile(configPath, ts.sys.readFile);
101
+
102
+ if (configFile.error) {
103
+ throw new Error(`解析 tsconfig.json 失败: ${configFile.error.messageText}`);
104
+ }
105
+
106
+ return configFile.config;
107
+ } catch (error) {
108
+ if (error.code === 'MODULE_NOT_FOUND') {
109
+ throw new Error('请先安装 typescript: npm install typescript --save-dev');
110
+ }
111
+ throw error;
112
+ }
113
+ }
114
+
115
+ common = {
116
+ getFramework,
117
+ errorLog,
118
+ warningLog,
119
+ successLog,
120
+ parseTsConfigWithTypeScript
121
+ };
122
+ return common;
123
+ }
124
+
125
+ exports.__require = requireCommon;
@@ -0,0 +1,129 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const require$$2 = require('lodash');
6
+ const AddNeoRequirePlugin = require('../plugins/AddNeoRequirePlugin.js');
7
+ const createCommonModulesCode = require('./cmpUtils/createCommonModulesCode.js');
8
+ const neoRequire = require('../neo/neoRequire.js');
9
+ const index = require('../config/index.js');
10
+
11
+ var configureNeoBuild_1;
12
+ var hasRequiredConfigureNeoBuild;
13
+
14
+ function requireConfigureNeoBuild () {
15
+ if (hasRequiredConfigureNeoBuild) return configureNeoBuild_1;
16
+ hasRequiredConfigureNeoBuild = 1;
17
+ const _ = require$$2;
18
+ const AddNeoRequirePlugin$1 = AddNeoRequirePlugin.__require();
19
+ const createCommonModulesCode$1 = createCommonModulesCode.__require();
20
+ const { getExternalsByNeoCommonModules } = neoRequire.__require();
21
+ const curConfig = index.__require(); // 获取当前项目根目录下的配置文件
22
+
23
+ // neo.config.js 中的添加的 Neo 共享依赖模块配置
24
+ const neoCommonModule = curConfig.neoCommonModule || {};
25
+ // 自定义组件 需要剔除的依赖模块
26
+ const cmpNeoExternals = neoCommonModule.externals || [];
27
+
28
+ // 组件目录
29
+ curConfig.componentsDir || './src/components';
30
+
31
+ /**
32
+ * 添加 AddNeoRequirePlugin 到 webpack 配置
33
+ * @param {object} webpackConfig webpack 配置对象
34
+ * @param {object} [options] 选项
35
+ * @param {boolean} [options.verbose] 是否启用详细日志,默认为 false
36
+ */
37
+ function addNeoRequirePlugin(webpackConfig, options = {}) {
38
+ const { verbose = false } = options;
39
+ const plugin = new AddNeoRequirePlugin$1({ verbose });
40
+
41
+ if (webpackConfig && webpackConfig.plugins && Array.isArray(webpackConfig.plugins)) {
42
+ webpackConfig.plugins.push(plugin);
43
+ } else {
44
+ webpackConfig.plugins = [plugin];
45
+ }
46
+ }
47
+
48
+ /**
49
+ * 添加 Neo externals 配置
50
+ * @param {object} config 配置对象(dev 或 build2lib)
51
+ * @param {object} externalsConfig 现有的 externals 配置
52
+ */
53
+ function addNeoExternals(config, externalsConfig) {
54
+ const externals = getExternalsByNeoCommonModules(cmpNeoExternals);
55
+ if (externalsConfig && _.isPlainObject(externalsConfig)) {
56
+ config.externals = Object.assign(externalsConfig, externals);
57
+ } else {
58
+ config.externals = externals;
59
+ }
60
+ }
61
+
62
+ /**
63
+ * 创建并注入 commonModulesCode 到 entry
64
+ * @param {object} config 配置对象(dev 或 build2lib)
65
+ * @param {array} cmpTypes 组件类型列表
66
+ * @param {object} [options] 选项
67
+ * @param {boolean} [options.excludeModel] 是否排除 Model 结尾的 entry,默认为 false
68
+ */
69
+ function injectCommonModulesCode(config, options = {}) {
70
+ const { cmpTypes, defaultExports, excludeModel = false } = options;
71
+
72
+ // 添加默认导出
73
+ if (defaultExports && _.isPlainObject(defaultExports)) {
74
+ if (neoCommonModule.exports && _.isPlainObject(neoCommonModule.exports)) {
75
+ neoCommonModule.exports = Object.assign(neoCommonModule.exports, defaultExports);
76
+ } else if (neoCommonModule.exports && _.isArray(neoCommonModule.exports)) {
77
+ // 先将数组格式改成对象格式
78
+ neoCommonModule.exports.forEach((item) => {
79
+ if (_.isString(item)) {
80
+ neoCommonModule.exports[item] = item;
81
+ }
82
+ });
83
+ neoCommonModule.exports = Object.assign(neoCommonModule.exports, defaultExports);
84
+ } else {
85
+ neoCommonModule.exports = defaultExports;
86
+ }
87
+ }
88
+
89
+ const commonModulesFilePath = createCommonModulesCode$1(neoCommonModule, cmpTypes);
90
+
91
+ if (commonModulesFilePath && config.entry) {
92
+ Object.keys(config.entry).forEach((name) => {
93
+ // 如果 excludeModel 为 true,排除 Model 结尾的文件
94
+ if (!excludeModel || !name.endsWith('Model')) {
95
+ config.entry[name] = [commonModulesFilePath].concat(config.entry[name]);
96
+ }
97
+ });
98
+ }
99
+ }
100
+
101
+ /**
102
+ * 配置 webpack 插件、externals 和 commonModulesCode(用于 linkDebug、publish2oss、pushCmp)
103
+ * @param {object} config 配置对象(dev 或 build2lib)
104
+ * @param {object} [options] 选项
105
+ * @param {array} [options.cmpTypes] 组件类型列表
106
+ * @param {object} [options.defaultExports] 默认导出
107
+ * @param {boolean} [options.verbose] 是否启用详细日志,默认为 false
108
+ * @param {boolean} [options.excludeModel] 是否排除 Model 结尾的 entry,默认为 false
109
+ */
110
+ function configureNeoBuild(config, options = {}) {
111
+ const { cmpTypes, defaultExports, verbose = false, excludeModel = false } = options;
112
+
113
+ // 添加自定义 webpack 插件
114
+ addNeoRequirePlugin(curConfig.webpack, { verbose });
115
+
116
+ // 添加内置 Neo 的 externals 配置
117
+ addNeoExternals(config, config.externals);
118
+
119
+ // 创建并注入 commonModulesCode
120
+ injectCommonModulesCode(config, { cmpTypes, defaultExports, excludeModel });
121
+ }
122
+
123
+ configureNeoBuild_1 = {
124
+ configureNeoBuild
125
+ };
126
+ return configureNeoBuild_1;
127
+ }
128
+
129
+ exports.__require = requireConfigureNeoBuild;
@@ -0,0 +1,80 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const getEntries = require('./projectUtils/getEntries.js');
6
+ const getEntriesWithAutoRegister = require('./projectUtils/getEntriesWithAutoRegister.js');
7
+
8
+ var generateEntries_1;
9
+ var hasRequiredGenerateEntries;
10
+
11
+ function requireGenerateEntries () {
12
+ if (hasRequiredGenerateEntries) return generateEntries_1;
13
+ hasRequiredGenerateEntries = 1;
14
+ const getEntries$1 = getEntries.__require();
15
+ const getEntriesWithAutoRegister$1 = getEntriesWithAutoRegister.__require();
16
+
17
+ /**
18
+ * 生成 entry 配置
19
+ * @param {object} options 配置选项
20
+ * @param {object} options.configEntry 当前配置中的 entry(如果已存在则直接返回)
21
+ * @param {boolean} options.disableAutoRegister 是否禁用自动注册
22
+ * @param {string} options.componentsDir 组件目录路径
23
+ * @param {string} options.entryType entry 类型:'widget' | 'linkDebug',默认为 'widget'
24
+ * @param {string} [options.cmpType] 可选的组件类型,如果指定则只生成该组件的 entry
25
+ */
26
+ function generateEntries({
27
+ configEntry,
28
+ disableAutoRegister,
29
+ componentsDir,
30
+ entryType = 'widget',
31
+ cmpType
32
+ }) {
33
+ // 如果已配置 entry 且不需要强制获取 cmpTypes,直接返回
34
+ if (configEntry && Object.keys(configEntry).length > 0) {
35
+ return {
36
+ entries: configEntry,
37
+ cmpTypes: []
38
+ };
39
+ }
40
+
41
+ // 根据 disableAutoRegister 选择不同的生成方法
42
+ let entriesResult;
43
+ if (disableAutoRegister) {
44
+ // disableAutoRegister 为 true 时,仅自动生成入口文件(不自动注册)
45
+ entriesResult = getEntries$1(componentsDir, cmpType);
46
+ } else {
47
+ // 自动生成入口文件(并自动创建对应的注册文件)
48
+ entriesResult = getEntriesWithAutoRegister$1(componentsDir, cmpType);
49
+ }
50
+
51
+ // 根据 entryType 选择对应的 entries
52
+ let entries;
53
+ if (entryType === 'linkDebug') {
54
+ entries = entriesResult.linkDebugEntries || {};
55
+ } else {
56
+ entries = entriesResult.widgetEntries || {};
57
+ }
58
+
59
+ const cmpTypes = entriesResult.cmpTypes || [];
60
+
61
+ // 验证 entries 是否有效(仅在需要生成新 entry 时验证)
62
+ if (!entries || Object.keys(entries).length === 0) {
63
+ const defaultComponentsDir = componentsDir || './src/components';
64
+ throw new Error(
65
+ `未识别到自定义组件,请检查 ${defaultComponentsDir} 目录下是否存在自定义组件。`
66
+ );
67
+ }
68
+
69
+ return {
70
+ entries: entries || configEntry || {},
71
+ cmpTypes,
72
+ defaultExports: entriesResult.defaultExports || {}
73
+ };
74
+ }
75
+
76
+ generateEntries_1 = generateEntries;
77
+ return generateEntries_1;
78
+ }
79
+
80
+ exports.__require = requireGenerateEntries;
@@ -0,0 +1,30 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const require$$1 = require('node:path');
6
+ const require$$0 = require('akfun');
7
+
8
+ var neoConfigInit;
9
+ var hasRequiredNeoConfigInit;
10
+
11
+ function requireNeoConfigInit () {
12
+ if (hasRequiredNeoConfigInit) return neoConfigInit;
13
+ hasRequiredNeoConfigInit = 1;
14
+ const path = require$$1;
15
+ const { createFile } = require$$0;
16
+
17
+ // 将脚手架的默认配置文件拷贝到当前项目根目录
18
+ const createDefaultConfig = function (_configProjectName) {
19
+ const configProjectName = _configProjectName || 'neo.config.js';
20
+ createFile(
21
+ path.resolve(__dirname, `../initData/${configProjectName}`),
22
+ path.resolve(process.cwd(), `./${configProjectName}`)
23
+ );
24
+ };
25
+
26
+ neoConfigInit = createDefaultConfig;
27
+ return neoConfigInit;
28
+ }
29
+
30
+ exports.__require = requireNeoConfigInit;
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ var neoParams;
6
+ var hasRequiredNeoParams;
7
+
8
+ function requireNeoParams () {
9
+ if (hasRequiredNeoParams) return neoParams;
10
+ hasRequiredNeoParams = 1;
11
+ let consoleTag = '[neo-cmp-cli]'; // 输出标记
12
+
13
+ function setConsoleTag(newText) {
14
+ consoleTag = newText;
15
+ }
16
+
17
+ neoParams = {
18
+ get consoleTag() {
19
+ return consoleTag;
20
+ },
21
+ setConsoleTag
22
+ };
23
+ return neoParams;
24
+ }
25
+
26
+ exports.__require = requireNeoParams;
@@ -0,0 +1,40 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const require$$1 = require('node:path');
6
+ const require$$0 = require('node:fs');
7
+
8
+ var pathUtils;
9
+ var hasRequiredPathUtils;
10
+
11
+ function requirePathUtils () {
12
+ if (hasRequiredPathUtils) return pathUtils;
13
+ hasRequiredPathUtils = 1;
14
+ const path = require$$1;
15
+ const fs = require$$0;
16
+
17
+ // 当前命令执行的路径
18
+ const currentRoot = () => fs.realpathSync(process.cwd());
19
+ const resolveToCurrentRoot = (filePath) => path.resolve(currentRoot(), filePath);
20
+ const resolveToCurrentDist = (filePath, outDir) =>
21
+ path.resolve(currentRoot(), outDir || 'dist/', filePath);
22
+ const currentSrc = () => resolveToCurrentRoot('src');
23
+ const currentBuild = () => resolveToCurrentRoot('build');
24
+
25
+ // 获取当前项目的package文件(从当前命令执行的路径下查找)
26
+ const catchCurPackageJson = () => resolveToCurrentRoot('package.json');
27
+
28
+ pathUtils = {
29
+ currentRoot,
30
+ resolveToCurrentRoot,
31
+ resolveToCurrentDist,
32
+ resolve: resolveToCurrentRoot,
33
+ currentSrc,
34
+ currentBuild,
35
+ catchCurPackageJson
36
+ };
37
+ return pathUtils;
38
+ }
39
+
40
+ exports.__require = requirePathUtils;
@@ -0,0 +1,90 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ /**
6
+ * 文件名验证工具
7
+ * 验证规则:
8
+ * 1. 至少5个字符
9
+ * 2. 必须以字母开头
10
+ * 3. 只能包含字母、数字、连字符(-)
11
+ */
12
+
13
+ var projectNameValidator;
14
+ var hasRequiredProjectNameValidator;
15
+
16
+ function requireProjectNameValidator () {
17
+ if (hasRequiredProjectNameValidator) return projectNameValidator;
18
+ hasRequiredProjectNameValidator = 1;
19
+ /**
20
+ * 验证文件名是否符合规范
21
+ * @param {string} ProjectName 文件名(不包含路径和扩展名)
22
+ * @returns {Object} 验证结果对象
23
+ */
24
+ function validateProjectName(ProjectName) {
25
+ const errors = [];
26
+
27
+ // 检查文件名是否为空
28
+ if (!ProjectName || ProjectName.trim().length === 0) {
29
+ errors.push('文件名不能为空');
30
+ return { isValid: false, errors };
31
+ }
32
+
33
+ // 检查长度是否至少5个字符
34
+ if (ProjectName.length < 5) {
35
+ errors.push(`文件名长度必须至少5个字符,当前长度: ${ProjectName.length}`);
36
+ }
37
+
38
+ // 检查是否以字母开头
39
+ if (!/^[a-zA-Z]/.test(ProjectName)) {
40
+ errors.push('文件名必须以字母开头');
41
+ }
42
+
43
+ // 检查是否只包含字母、数字、连字符
44
+ if (!/^[a-zA-Z][a-zA-Z0-9-]*$/.test(ProjectName)) {
45
+ errors.push('文件名只能包含字母、数字和连字符(-),且必须以字母开头');
46
+ }
47
+
48
+ // 检查是否包含连续连字符
49
+ if (ProjectName.includes('--')) {
50
+ errors.push('文件名不能包含连续连字符(--)');
51
+ }
52
+
53
+ // 检查是否以连字符结尾
54
+ if (ProjectName.endsWith('-')) {
55
+ errors.push('文件名不能以连字符结尾');
56
+ }
57
+
58
+ return {
59
+ isValid: errors.length === 0,
60
+ errors
61
+ };
62
+ }
63
+
64
+ /**
65
+ * 验证文件名并返回布尔值
66
+ * @param {string} ProjectName 文件名
67
+ * @returns {boolean} 是否有效
68
+ */
69
+ function isValidProjectName(ProjectName) {
70
+ return validateProjectName(ProjectName).isValid;
71
+ }
72
+
73
+ /**
74
+ * 获取文件名验证的错误信息
75
+ * @param {string} ProjectName 文件名
76
+ * @returns {Array} 错误信息数组
77
+ */
78
+ function getProjectNameErrors(ProjectName) {
79
+ return validateProjectName(ProjectName).errors;
80
+ }
81
+
82
+ projectNameValidator = {
83
+ validateProjectName,
84
+ isValidProjectName,
85
+ getProjectNameErrors
86
+ };
87
+ return projectNameValidator;
88
+ }
89
+
90
+ exports.__require = requireProjectNameValidator;
@@ -0,0 +1,81 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const require$$0 = require('fs-extra');
6
+ const require$$1 = require('node:path');
7
+ const neoParams = require('../neoParams.js');
8
+ const replaceInPackage = require('../replaceInPackage.js');
9
+ const resetPackageVersion = require('../resetPackageVersion.js');
10
+ const autoEntryRootDir = require('../autoEntryRootDir.js');
11
+ const hasNeoProject = require('./hasNeoProject.js');
12
+
13
+ var createCmpProjectByTemplate;
14
+ var hasRequiredCreateCmpProjectByTemplate;
15
+
16
+ function requireCreateCmpProjectByTemplate () {
17
+ if (hasRequiredCreateCmpProjectByTemplate) return createCmpProjectByTemplate;
18
+ hasRequiredCreateCmpProjectByTemplate = 1;
19
+ const fs = require$$0;
20
+ const path = require$$1;
21
+ const { consoleTag } = neoParams.__require(); // 输出标记
22
+ const { replaceInPackage: replaceInPackage$1 } = replaceInPackage.__require();
23
+ const { resetPackageVersion: resetPackageVersion$1 } = resetPackageVersion.__require();
24
+ const autoEntryRootDir$1 = autoEntryRootDir.__require();
25
+ const hasNeoProject$1 = hasNeoProject.__require();
26
+
27
+ const cmpTemplateList = {
28
+ 'react-ts': {
29
+ projectName: 'empty-custom-cmp-template',
30
+ dir: path.resolve(__dirname, '../../../template/empty-custom-cmp-template')
31
+ }
32
+ };
33
+
34
+ /**
35
+ * 通过拷贝模板创建自定义组件
36
+ * @param {*} projectName 自定义组件项目名称
37
+ * @param {*} type 自定义组件类型
38
+ */
39
+ createCmpProjectByTemplate = function (projectName, type = 'react-ts') {
40
+ const finalProjectPath = path.resolve(process.cwd(), projectName);
41
+
42
+ if (hasNeoProject$1()) {
43
+ console.error(
44
+ `${consoleTag}创建自定义组件项目失败,当前目录(${process.cwd()})已经是一个自定义组件项目,请勿重复创建。`
45
+ );
46
+ process.exit(1);
47
+ }
48
+
49
+ if (fs.existsSync(finalProjectPath)) {
50
+ console.error(
51
+ `${consoleTag}创建自定义组件项目失败,当前已存在(${projectName})项目,请勿创建重名项目。`
52
+ );
53
+ process.exit(1);
54
+ }
55
+
56
+ const curCmpTemplate = cmpTemplateList[type];
57
+ if (!curCmpTemplate) {
58
+ console.error(`${consoleTag}创建自定义组件项目失败,当前不支持${type}类型。`);
59
+ process.exit(1);
60
+ }
61
+
62
+ const currentTemplateDir = curCmpTemplate.dir;
63
+ const finalProjectName = projectName || 'neoCustomCmp';
64
+
65
+ fs.copy(currentTemplateDir, finalProjectPath)
66
+ .then(() => {
67
+ replaceInPackage$1(finalProjectPath, curCmpTemplate.projectName, finalProjectName);
68
+ replaceInPackage$1(finalProjectPath, 'wibetter', 'xxx');
69
+ replaceInPackage$1(finalProjectPath, 'neo自定义组件模板', 'neo自定义组件');
70
+ resetPackageVersion$1(finalProjectPath);
71
+
72
+ console.log(`${consoleTag}已创建自定义组件项目(${finalProjectName})!`);
73
+ // 自动切换到项目根目录
74
+ autoEntryRootDir$1(finalProjectPath);
75
+ })
76
+ .catch((err) => console.error(`${consoleTag}自定义组件模板下载失败:`, err));
77
+ };
78
+ return createCmpProjectByTemplate;
79
+ }
80
+
81
+ exports.__require = requireCreateCmpProjectByTemplate;