swico 0.6.0-beta15 → 0.6.0-beta17
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/package.json +1 -1
- package/src/command/build.js +1 -0
- package/src/command/start.js +3 -2
- package/src/utils/config.js +3 -8
- package/src/utils/tools.d.ts +1 -0
- package/src/utils/tools.js +18 -2
package/package.json
CHANGED
package/src/command/build.js
CHANGED
|
@@ -60,6 +60,7 @@ function default_1() {
|
|
|
60
60
|
case 1:
|
|
61
61
|
projectConfig = _a.sent();
|
|
62
62
|
entryPath = projectConfig.entryPath, templatePath = projectConfig.templatePath, projectPath = projectConfig.projectPath, customConfig = projectConfig.customConfig, templateType = projectConfig.templateType;
|
|
63
|
+
(0, tools_1.initIndexFile)(templateType);
|
|
63
64
|
return [4, (0, webpack_prod_1.default)({
|
|
64
65
|
entryPath: entryPath,
|
|
65
66
|
templatePath: templatePath,
|
package/src/command/start.js
CHANGED
|
@@ -126,7 +126,7 @@ var restartServer = function () {
|
|
|
126
126
|
};
|
|
127
127
|
function start() {
|
|
128
128
|
return __awaiter(this, void 0, void 0, function () {
|
|
129
|
-
var _a, projectConfig, projectPath, startConfig, compiler, devServer, e_1, strErr;
|
|
129
|
+
var _a, projectConfig, projectPath, templateType, startConfig, compiler, devServer, e_1, strErr;
|
|
130
130
|
return __generator(this, function (_b) {
|
|
131
131
|
switch (_b.label) {
|
|
132
132
|
case 0:
|
|
@@ -145,7 +145,8 @@ function start() {
|
|
|
145
145
|
return [4, (0, config_1.getProjectConfig)('dev')];
|
|
146
146
|
case 4:
|
|
147
147
|
projectConfig = _b.sent();
|
|
148
|
-
projectPath = projectConfig.projectPath;
|
|
148
|
+
projectPath = projectConfig.projectPath, templateType = projectConfig.templateType;
|
|
149
|
+
(0, tools_1.initIndexFile)(templateType);
|
|
149
150
|
return [4, (0, webpack_dev_1.default)(projectConfig)];
|
|
150
151
|
case 5:
|
|
151
152
|
startConfig = _b.sent();
|
package/src/utils/config.js
CHANGED
|
@@ -226,9 +226,7 @@ var initCliIndexFile = function (templateType) { return __awaiter(void 0, void 0
|
|
|
226
226
|
case 0:
|
|
227
227
|
targetPath = path_1.default.resolve(__dirname, '../index.js');
|
|
228
228
|
targetTypesPath = path_1.default.resolve(__dirname, '../index.d.ts');
|
|
229
|
-
|
|
230
|
-
case 1:
|
|
231
|
-
replaceFileText = _a.sent();
|
|
229
|
+
replaceFileText = fs_extra_1.default.readFileSync(path_1.default.resolve(__dirname, "../index.".concat(templateType, ".js")), 'utf8');
|
|
232
230
|
fileTypesText = fs_extra_1.default.readFileSync(path_1.default.resolve(__dirname, "../index.".concat(templateType, ".d.ts")), 'utf8');
|
|
233
231
|
if (templateType === 'react') {
|
|
234
232
|
formatHooksPath = path_1.default
|
|
@@ -237,10 +235,10 @@ var initCliIndexFile = function (templateType) { return __awaiter(void 0, void 0
|
|
|
237
235
|
replaceFileText = replaceFileText.replaceAll('require("./template/react/hooks");', "require(\"".concat(formatHooksPath, "\");"));
|
|
238
236
|
}
|
|
239
237
|
return [4, (0, tools_1.writeFile)(targetPath, replaceFileText)];
|
|
240
|
-
case
|
|
238
|
+
case 1:
|
|
241
239
|
_a.sent();
|
|
242
240
|
return [4, (0, tools_1.writeFile)(targetTypesPath, fileTypesText)];
|
|
243
|
-
case
|
|
241
|
+
case 2:
|
|
244
242
|
_a.sent();
|
|
245
243
|
return [2];
|
|
246
244
|
}
|
|
@@ -309,13 +307,10 @@ var initTemplateConfig = function (routerConfig, templateType, env) {
|
|
|
309
307
|
case 0:
|
|
310
308
|
console.log('0');
|
|
311
309
|
copyTargetPath = path_1.default.resolve(projectPath, './src/.swico');
|
|
312
|
-
console.log('0.5');
|
|
313
310
|
copyFileNameList = getCopyFileNameList(templateType, env);
|
|
314
|
-
console.log('1');
|
|
315
311
|
return [4, (0, tools_1.copyDirFiles)(path_1.default.resolve(__dirname, "../template/".concat(templateType)), copyTargetPath, function (fileName) { return copyFileNameList.includes(fileName); })];
|
|
316
312
|
case 1:
|
|
317
313
|
_a.sent();
|
|
318
|
-
console.log('2');
|
|
319
314
|
return [4, formatRouterConfig(routerConfig, templateType, env)];
|
|
320
315
|
case 2:
|
|
321
316
|
_a.sent();
|
package/src/utils/tools.d.ts
CHANGED
package/src/utils/tools.js
CHANGED
|
@@ -39,7 +39,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.writeFile = exports.toast = exports.getPort = exports.copyDirFiles = void 0;
|
|
42
|
+
exports.initIndexFile = exports.writeFile = exports.toast = exports.getPort = exports.copyDirFiles = void 0;
|
|
43
43
|
var portfinder_1 = __importDefault(require("portfinder"));
|
|
44
44
|
var fs_extra_1 = __importDefault(require("fs-extra"));
|
|
45
45
|
var path_1 = __importDefault(require("path"));
|
|
@@ -59,7 +59,6 @@ var copyDirFiles = function (src, dest, filter) { return __awaiter(void 0, void
|
|
|
59
59
|
files.forEach(function (file) {
|
|
60
60
|
var srcPath = path_1.default.join(src, file);
|
|
61
61
|
var destPath = path_1.default.join(dest, file);
|
|
62
|
-
console.log('1.5', srcPath, destPath);
|
|
63
62
|
var srcStat = fs_extra_1.default.statSync(srcPath);
|
|
64
63
|
if (srcStat.isDirectory()) {
|
|
65
64
|
_copy(srcPath, destPath);
|
|
@@ -143,3 +142,20 @@ var writeFile = function (sourcePath, text) {
|
|
|
143
142
|
});
|
|
144
143
|
};
|
|
145
144
|
exports.writeFile = writeFile;
|
|
145
|
+
var initIndexFile = function (tempalteType) { return __awaiter(void 0, void 0, void 0, function () {
|
|
146
|
+
var fileText, targetPath;
|
|
147
|
+
return __generator(this, function (_a) {
|
|
148
|
+
switch (_a.label) {
|
|
149
|
+
case 0:
|
|
150
|
+
if (!(tempalteType === 'react')) return [3, 2];
|
|
151
|
+
fileText = fs_extra_1.default.readFileSync(path_1.default.resolve(__dirname, '../index.react.js'), 'utf8');
|
|
152
|
+
targetPath = path_1.default.resolve(__dirname, '../index.js');
|
|
153
|
+
return [4, (0, exports.writeFile)(targetPath, fileText)];
|
|
154
|
+
case 1:
|
|
155
|
+
_a.sent();
|
|
156
|
+
_a.label = 2;
|
|
157
|
+
case 2: return [2];
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}); };
|
|
161
|
+
exports.initIndexFile = initIndexFile;
|