swico 0.6.0-beta24 → 0.6.0-beta25
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 -1
- package/src/command/start.js +1 -1
- package/src/utils/tools.d.ts +2 -1
- package/src/utils/tools.js +4 -3
package/package.json
CHANGED
package/src/command/build.js
CHANGED
|
@@ -56,7 +56,7 @@ function default_1() {
|
|
|
56
56
|
process.env.SWICO_ENV = 'prod';
|
|
57
57
|
tools_1.toast.info("Swico v".concat(package_json_1.default.version));
|
|
58
58
|
tools_1.toast.info('Initializing Swico production config...');
|
|
59
|
-
return [4, (0, tools_1.initIndexFile)()];
|
|
59
|
+
return [4, (0, tools_1.initIndexFile)('prod')];
|
|
60
60
|
case 1:
|
|
61
61
|
_a.sent();
|
|
62
62
|
return [4, (0, config_1.getProjectConfig)('prod')];
|
package/src/command/start.js
CHANGED
|
@@ -133,7 +133,7 @@ function start() {
|
|
|
133
133
|
process.env.SWICO_ENV = 'dev';
|
|
134
134
|
tools_1.toast.info("Swico v".concat(package_json_1.default.version));
|
|
135
135
|
tools_1.toast.info('Initializing Swico development config...\n');
|
|
136
|
-
return [4, (0, tools_1.initIndexFile)()];
|
|
136
|
+
return [4, (0, tools_1.initIndexFile)('dev')];
|
|
137
137
|
case 1:
|
|
138
138
|
_b.sent();
|
|
139
139
|
if (!(envPort !== null && envPort !== void 0)) return [3, 2];
|
package/src/utils/tools.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { GlobalData } from './config';
|
|
1
2
|
export declare const copyDirFiles: (src: any, dest: any, filter?: (fileName: any) => boolean) => Promise<any>;
|
|
2
3
|
export declare const getPort: () => Promise<number>;
|
|
3
4
|
export declare const toast: {
|
|
@@ -6,4 +7,4 @@ export declare const toast: {
|
|
|
6
7
|
warning: (message: string | string[]) => void;
|
|
7
8
|
};
|
|
8
9
|
export declare const writeFile: (sourcePath: any, text: any) => Promise<unknown>;
|
|
9
|
-
export declare const initIndexFile: () => Promise<void>;
|
|
10
|
+
export declare const initIndexFile: (env: GlobalData['env']) => Promise<void>;
|
package/src/utils/tools.js
CHANGED
|
@@ -166,15 +166,16 @@ var writeFile = function (sourcePath, text) {
|
|
|
166
166
|
});
|
|
167
167
|
};
|
|
168
168
|
exports.writeFile = writeFile;
|
|
169
|
-
var initIndexFile = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
170
|
-
var fileText, targetPath, formatHooksPath;
|
|
169
|
+
var initIndexFile = function (env) { return __awaiter(void 0, void 0, void 0, function () {
|
|
170
|
+
var envPath, fileText, targetPath, formatHooksPath;
|
|
171
171
|
return __generator(this, function (_a) {
|
|
172
172
|
switch (_a.label) {
|
|
173
173
|
case 0:
|
|
174
|
+
envPath = env === 'dev' ? '/' : '/.prod/';
|
|
174
175
|
fileText = fs_extra_1.default.readFileSync(path_1.default.resolve(__dirname, '../index.js'), 'utf8');
|
|
175
176
|
targetPath = path_1.default.resolve(__dirname, '../index.js');
|
|
176
177
|
formatHooksPath = path_1.default
|
|
177
|
-
.resolve(process.cwd(),
|
|
178
|
+
.resolve(process.cwd(), "./src/.swico".concat(envPath, "hooks.js"))
|
|
178
179
|
.replaceAll('\\', '/');
|
|
179
180
|
console.log('replace', "require(\"".concat(formatHooksPath, "\");"));
|
|
180
181
|
fileText = fileText.replaceAll("require(\"".concat(formatHooksPath, "\");"), 'require("./template/react/hooks");');
|