swico 0.6.0-beta14 → 0.6.0-beta16
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/start.js +6 -2
- package/src/utils/config.js +4 -7
- package/src/utils/tools.d.ts +1 -0
- package/src/utils/tools.js +18 -2
package/package.json
CHANGED
package/src/command/start.js
CHANGED
|
@@ -126,13 +126,14 @@ 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:
|
|
133
133
|
process.env.SWICO_ENV = 'dev';
|
|
134
134
|
tools_1.toast.info("Swico v".concat(package_json_1.default.version));
|
|
135
135
|
spinner.start('Initializing Swico development config...\n');
|
|
136
|
+
console.log('11');
|
|
136
137
|
if (!(envPort !== null && envPort !== void 0)) return [3, 1];
|
|
137
138
|
_a = envPort;
|
|
138
139
|
return [3, 3];
|
|
@@ -145,7 +146,10 @@ function start() {
|
|
|
145
146
|
return [4, (0, config_1.getProjectConfig)('dev')];
|
|
146
147
|
case 4:
|
|
147
148
|
projectConfig = _b.sent();
|
|
148
|
-
|
|
149
|
+
console.log('22');
|
|
150
|
+
projectPath = projectConfig.projectPath, templateType = projectConfig.templateType;
|
|
151
|
+
console.log('33');
|
|
152
|
+
(0, tools_1.initHookRef)(templateType);
|
|
149
153
|
return [4, (0, webpack_dev_1.default)(projectConfig)];
|
|
150
154
|
case 5:
|
|
151
155
|
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
|
}
|
|
@@ -307,13 +305,12 @@ var initTemplateConfig = function (routerConfig, templateType, env) {
|
|
|
307
305
|
return __generator(this, function (_a) {
|
|
308
306
|
switch (_a.label) {
|
|
309
307
|
case 0:
|
|
308
|
+
console.log('0');
|
|
310
309
|
copyTargetPath = path_1.default.resolve(projectPath, './src/.swico');
|
|
311
310
|
copyFileNameList = getCopyFileNameList(templateType, env);
|
|
312
|
-
console.log('1');
|
|
313
311
|
return [4, (0, tools_1.copyDirFiles)(path_1.default.resolve(__dirname, "../template/".concat(templateType)), copyTargetPath, function (fileName) { return copyFileNameList.includes(fileName); })];
|
|
314
312
|
case 1:
|
|
315
313
|
_a.sent();
|
|
316
|
-
console.log('2');
|
|
317
314
|
return [4, formatRouterConfig(routerConfig, templateType, env)];
|
|
318
315
|
case 2:
|
|
319
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.initHookRef = 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 initHookRef = 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.initHookRef = initHookRef;
|