@modern-js/app-tools 2.1.0 → 2.2.1-alpha.0
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/CHANGELOG.md +47 -0
- package/dist/js/modern/analyze/constants.js +2 -1
- package/dist/js/modern/analyze/index.js +14 -4
- package/dist/js/modern/analyze/nestedRoutes.js +17 -1
- package/dist/js/modern/builder/index.js +4 -4
- package/dist/js/modern/commands/dev.js +1 -23
- package/dist/js/modern/hooks.js +0 -2
- package/dist/js/modern/index.js +14 -2
- package/dist/js/modern/initialize/index.js +6 -2
- package/dist/js/modern/locale/en.js +3 -1
- package/dist/js/modern/locale/zh.js +3 -1
- package/dist/js/modern/utils/generateWatchFiles.js +55 -0
- package/dist/js/modern/utils/{getSpecifiedEntries.js → getSelectedEntries.js} +9 -8
- package/dist/js/node/analyze/constants.js +2 -1
- package/dist/js/node/analyze/index.js +11 -4
- package/dist/js/node/analyze/nestedRoutes.js +17 -1
- package/dist/js/node/builder/index.js +4 -4
- package/dist/js/node/commands/dev.js +1 -23
- package/dist/js/node/hooks.js +0 -2
- package/dist/js/node/index.js +9 -2
- package/dist/js/node/initialize/index.js +1 -2
- package/dist/js/node/locale/en.js +3 -1
- package/dist/js/node/locale/zh.js +3 -1
- package/dist/js/node/utils/{createFileWatcher.js → generateWatchFiles.js} +12 -66
- package/dist/js/node/utils/{getSpecifiedEntries.js → getSelectedEntries.js} +12 -11
- package/dist/js/treeshaking/analyze/constants.js +2 -1
- package/dist/js/treeshaking/analyze/index.js +24 -11
- package/dist/js/treeshaking/analyze/nestedRoutes.js +20 -3
- package/dist/js/treeshaking/builder/index.js +5 -5
- package/dist/js/treeshaking/commands/dev.js +13 -31
- package/dist/js/treeshaking/hooks.js +0 -2
- package/dist/js/treeshaking/index.js +15 -2
- package/dist/js/treeshaking/initialize/index.js +1 -2
- package/dist/js/treeshaking/locale/en.js +3 -1
- package/dist/js/treeshaking/locale/zh.js +3 -1
- package/dist/js/treeshaking/utils/{createFileWatcher.js → generateWatchFiles.js} +16 -85
- package/dist/js/treeshaking/utils/{getSpecifiedEntries.js → getSelectedEntries.js} +8 -7
- package/dist/types/analyze/constants.d.ts +1 -0
- package/dist/types/locale/en.d.ts +2 -0
- package/dist/types/locale/index.d.ts +4 -0
- package/dist/types/locale/zh.d.ts +2 -0
- package/dist/types/types/hooks.d.ts +0 -5
- package/dist/types/utils/generateWatchFiles.d.ts +3 -0
- package/dist/types/utils/getSelectedEntries.d.ts +6 -0
- package/package.json +24 -24
- package/dist/js/modern/utils/commands.js +0 -13
- package/dist/js/modern/utils/createFileWatcher.js +0 -115
- package/dist/js/node/utils/commands.js +0 -37
- package/dist/js/treeshaking/utils/commands.js +0 -10
- package/dist/types/utils/commands.d.ts +0 -2
- package/dist/types/utils/createFileWatcher.d.ts +0 -4
- package/dist/types/utils/getSpecifiedEntries.d.ts +0 -2
|
@@ -147,10 +147,8 @@ var __generator = this && this.__generator || function(thisArg, body) {
|
|
|
147
147
|
};
|
|
148
148
|
}
|
|
149
149
|
};
|
|
150
|
-
import crypto from "crypto";
|
|
151
|
-
import fs from "fs";
|
|
152
150
|
import path from "path";
|
|
153
|
-
import {
|
|
151
|
+
import { fs, getServerConfig } from "@modern-js/utils";
|
|
154
152
|
var getPackageConfig = function(appDirectory, packageJsonConfig) {
|
|
155
153
|
var PACKAGE_JSON_CONFIG_NAME = "modernConfig";
|
|
156
154
|
var json = JSON.parse(fs.readFileSync(path.resolve(appDirectory, "./package.json"), "utf8"));
|
|
@@ -181,29 +179,17 @@ var addServerConfigToDeps = function() {
|
|
|
181
179
|
return _ref.apply(this, arguments);
|
|
182
180
|
};
|
|
183
181
|
}();
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
var
|
|
190
|
-
var _ref = _asyncToGenerator(function(appContext, configDir, hooksRunner) {
|
|
191
|
-
var appDirectory, configFile, extraFiles, configPath, dependencies, watched, watcher;
|
|
182
|
+
function generateWatchFiles(appContext, configDir) {
|
|
183
|
+
return _generateWatchFiles.apply(this, arguments);
|
|
184
|
+
}
|
|
185
|
+
function _generateWatchFiles() {
|
|
186
|
+
_generateWatchFiles = _asyncToGenerator(function(appContext, configDir) {
|
|
187
|
+
var appDirectory, configFile, configPath, dependencies;
|
|
192
188
|
return __generator(this, function(_state) {
|
|
193
189
|
switch(_state.label){
|
|
194
190
|
case 0:
|
|
195
|
-
if (!(isDev() || isTest())) return [
|
|
196
|
-
3,
|
|
197
|
-
3
|
|
198
|
-
];
|
|
199
191
|
appDirectory = appContext.appDirectory, configFile = appContext.configFile;
|
|
200
|
-
|
|
201
|
-
4,
|
|
202
|
-
hooksRunner.watchFiles()
|
|
203
|
-
];
|
|
204
|
-
case 1:
|
|
205
|
-
extraFiles = _state.sent();
|
|
206
|
-
configPath = path.join(appDirectory, configDir);
|
|
192
|
+
configPath = path.join(appDirectory, configDir || "");
|
|
207
193
|
dependencies = getPackageConfig(appContext.appDirectory, appContext.packageName) ? [
|
|
208
194
|
path.resolve(appDirectory, "./package.json")
|
|
209
195
|
] : [];
|
|
@@ -211,73 +197,18 @@ var createFileWatcher = function() {
|
|
|
211
197
|
4,
|
|
212
198
|
addServerConfigToDeps(dependencies, appContext.appDirectory, appContext.serverConfigFile)
|
|
213
199
|
];
|
|
214
|
-
case
|
|
200
|
+
case 1:
|
|
215
201
|
_state.sent();
|
|
216
|
-
watched = [
|
|
217
|
-
"".concat(configPath, "/html")
|
|
218
|
-
].concat(_toConsumableArray(extraFiles), _toConsumableArray(dependencies), [
|
|
219
|
-
configFile
|
|
220
|
-
]).filter(Boolean);
|
|
221
|
-
debug("watched: %o", watched);
|
|
222
|
-
watcher = chokidar.watch(watched, {
|
|
223
|
-
cwd: appDirectory,
|
|
224
|
-
ignoreInitial: true,
|
|
225
|
-
ignorePermissionErrors: true,
|
|
226
|
-
ignored: [
|
|
227
|
-
/node_modules/,
|
|
228
|
-
"**/__test__/**",
|
|
229
|
-
"**/*.test.(js|jsx|ts|tsx)",
|
|
230
|
-
"**/*.spec.(js|jsx|ts|tsx)",
|
|
231
|
-
"**/*.stories.(js|jsx|ts|tsx)"
|
|
232
|
-
]
|
|
233
|
-
});
|
|
234
|
-
watcher.on("change", function(changed) {
|
|
235
|
-
var lastHash = hashMap.get(changed);
|
|
236
|
-
var currentHash = md5(fs.readFileSync(path.join(appDirectory, changed), "utf8"));
|
|
237
|
-
if (currentHash !== lastHash) {
|
|
238
|
-
debug("file change: %s", changed);
|
|
239
|
-
hashMap.set(changed, currentHash);
|
|
240
|
-
hooksRunner.fileChange({
|
|
241
|
-
filename: changed,
|
|
242
|
-
eventType: "change"
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
watcher.on("add", function(name) {
|
|
247
|
-
debug("add file: %s", name);
|
|
248
|
-
var currentHash = md5(fs.readFileSync(path.join(appDirectory, name), "utf8"));
|
|
249
|
-
hashMap.set(name, currentHash);
|
|
250
|
-
hooksRunner.fileChange({
|
|
251
|
-
filename: name,
|
|
252
|
-
eventType: "add"
|
|
253
|
-
});
|
|
254
|
-
});
|
|
255
|
-
watcher.on("unlink", function(name) {
|
|
256
|
-
debug("remove file: %s", name);
|
|
257
|
-
if (hashMap.has(name)) {
|
|
258
|
-
hashMap.delete(name);
|
|
259
|
-
}
|
|
260
|
-
hooksRunner.fileChange({
|
|
261
|
-
filename: name,
|
|
262
|
-
eventType: "unlink"
|
|
263
|
-
});
|
|
264
|
-
});
|
|
265
|
-
watcher.on("error", function(err) {
|
|
266
|
-
throw err;
|
|
267
|
-
});
|
|
268
202
|
return [
|
|
269
203
|
2,
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
2
|
|
204
|
+
[
|
|
205
|
+
"".concat(configPath, "/html"),
|
|
206
|
+
configFile || "./config"
|
|
207
|
+
].concat(_toConsumableArray(dependencies))
|
|
275
208
|
];
|
|
276
209
|
}
|
|
277
210
|
});
|
|
278
211
|
});
|
|
279
|
-
return
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
}();
|
|
283
|
-
export { addServerConfigToDeps, createFileWatcher };
|
|
212
|
+
return _generateWatchFiles.apply(this, arguments);
|
|
213
|
+
}
|
|
214
|
+
export { addServerConfigToDeps, generateWatchFiles };
|
|
@@ -122,8 +122,9 @@ var __generator = this && this.__generator || function(thisArg, body) {
|
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
};
|
|
125
|
-
import { inquirer } from "@modern-js/utils";
|
|
126
|
-
|
|
125
|
+
import { chalk, inquirer } from "@modern-js/utils";
|
|
126
|
+
import { i18n, localeKeys } from "../locale";
|
|
127
|
+
var getSelectedEntries = function() {
|
|
127
128
|
var _ref = _asyncToGenerator(function(entry, entrypoints) {
|
|
128
129
|
var entryNames, selected;
|
|
129
130
|
return __generator(this, function(_state) {
|
|
@@ -149,10 +150,10 @@ var getSpecifiedEntries = function() {
|
|
|
149
150
|
type: "checkbox",
|
|
150
151
|
name: "selected",
|
|
151
152
|
choices: entryNames,
|
|
152
|
-
message:
|
|
153
|
+
message: i18n.t(localeKeys.command.dev.selectEntry),
|
|
153
154
|
validate: function validate(answer) {
|
|
154
155
|
if (answer.length < 1) {
|
|
155
|
-
return
|
|
156
|
+
return i18n.t(localeKeys.command.dev.requireEntry);
|
|
156
157
|
}
|
|
157
158
|
return true;
|
|
158
159
|
}
|
|
@@ -168,7 +169,7 @@ var getSpecifiedEntries = function() {
|
|
|
168
169
|
case 2:
|
|
169
170
|
entry.forEach(function(name) {
|
|
170
171
|
if (!entryNames.includes(name)) {
|
|
171
|
-
throw new Error("
|
|
172
|
+
throw new Error("Can not found entry ".concat(chalk.yellow(name), ", the entry should be one of ").concat(chalk.yellow(entryNames.join(", "))));
|
|
172
173
|
}
|
|
173
174
|
});
|
|
174
175
|
return [
|
|
@@ -178,8 +179,8 @@ var getSpecifiedEntries = function() {
|
|
|
178
179
|
}
|
|
179
180
|
});
|
|
180
181
|
});
|
|
181
|
-
return function
|
|
182
|
+
return function getSelectedEntries(entry, entrypoints) {
|
|
182
183
|
return _ref.apply(this, arguments);
|
|
183
184
|
};
|
|
184
185
|
}();
|
|
185
|
-
export {
|
|
186
|
+
export { getSelectedEntries };
|
|
@@ -10,6 +10,8 @@ declare const localeKeys: {
|
|
|
10
10
|
describe: string;
|
|
11
11
|
entry: string;
|
|
12
12
|
apiOnly: string;
|
|
13
|
+
selectEntry: string;
|
|
14
|
+
requireEntry: string;
|
|
13
15
|
};
|
|
14
16
|
build: {
|
|
15
17
|
describe: string;
|
|
@@ -44,6 +46,8 @@ declare const localeKeys: {
|
|
|
44
46
|
describe: string;
|
|
45
47
|
entry: string;
|
|
46
48
|
apiOnly: string;
|
|
49
|
+
selectEntry: string;
|
|
50
|
+
requireEntry: string;
|
|
47
51
|
};
|
|
48
52
|
build: {
|
|
49
53
|
describe: string;
|
|
@@ -76,11 +76,6 @@ export type AppToolsHooks = {
|
|
|
76
76
|
}, unknown>;
|
|
77
77
|
beforeDeploy: AsyncWorkflow<Record<string, any>, unknown>;
|
|
78
78
|
afterDeploy: AsyncWorkflow<Record<string, any>, unknown>;
|
|
79
|
-
watchFiles: ParallelWorkflow<void>;
|
|
80
|
-
fileChange: AsyncWorkflow<{
|
|
81
|
-
filename: string;
|
|
82
|
-
eventType: 'add' | 'change' | 'unlink';
|
|
83
|
-
}, void>;
|
|
84
79
|
beforeRestart: AsyncWorkflow<void, void>;
|
|
85
80
|
registerDev: ParallelWorkflow<void, DevToolData>;
|
|
86
81
|
beforeDevTask: ParallelWorkflow<DevToolData, void>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { IAppContext } from '../types';
|
|
2
|
+
export declare const addServerConfigToDeps: (dependencies: string[], appDirectory: string, serverConfigFile: string) => Promise<void>;
|
|
3
|
+
export declare function generateWatchFiles(appContext: IAppContext, configDir?: string): Promise<string[]>;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "2.1.0",
|
|
14
|
+
"version": "2.2.1-alpha.0",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -63,37 +63,37 @@
|
|
|
63
63
|
"@babel/runtime": "^7.18.0",
|
|
64
64
|
"@babel/traverse": "^7.18.0",
|
|
65
65
|
"@babel/types": "^7.18.0",
|
|
66
|
+
"@modern-js/builder": "2.2.0",
|
|
67
|
+
"@modern-js/builder-plugin-esbuild": "2.2.0",
|
|
68
|
+
"@modern-js/builder-plugin-node-polyfill": "2.2.0",
|
|
69
|
+
"@modern-js/builder-shared": "2.2.0",
|
|
70
|
+
"@modern-js/builder-webpack-provider": "2.2.0",
|
|
71
|
+
"@modern-js/core": "2.2.0",
|
|
72
|
+
"@modern-js/new-action": "2.2.0",
|
|
73
|
+
"@modern-js/node-bundle-require": "2.2.0",
|
|
74
|
+
"@modern-js/plugin": "2.2.0",
|
|
75
|
+
"@modern-js/plugin-data-loader": "2.2.0",
|
|
76
|
+
"@modern-js/plugin-i18n": "2.2.0",
|
|
77
|
+
"@modern-js/plugin-lint": "2.2.0",
|
|
78
|
+
"@modern-js/prod-server": "2.2.0",
|
|
79
|
+
"@modern-js/server": "2.2.0",
|
|
80
|
+
"@modern-js/types": "2.2.0",
|
|
81
|
+
"@modern-js/upgrade": "2.2.0",
|
|
82
|
+
"@modern-js/utils": "2.2.0",
|
|
66
83
|
"es-module-lexer": "^1.1.0",
|
|
67
|
-
"esbuild": "0.15.7"
|
|
68
|
-
"@modern-js/builder": "2.1.0",
|
|
69
|
-
"@modern-js/builder-plugin-esbuild": "2.1.0",
|
|
70
|
-
"@modern-js/builder-plugin-node-polyfill": "2.1.0",
|
|
71
|
-
"@modern-js/builder-shared": "2.1.0",
|
|
72
|
-
"@modern-js/builder-webpack-provider": "2.1.0",
|
|
73
|
-
"@modern-js/core": "2.1.0",
|
|
74
|
-
"@modern-js/new-action": "2.1.0",
|
|
75
|
-
"@modern-js/node-bundle-require": "2.1.0",
|
|
76
|
-
"@modern-js/plugin": "2.1.0",
|
|
77
|
-
"@modern-js/plugin-data-loader": "2.1.0",
|
|
78
|
-
"@modern-js/plugin-i18n": "2.1.0",
|
|
79
|
-
"@modern-js/plugin-lint": "2.1.0",
|
|
80
|
-
"@modern-js/prod-server": "2.1.0",
|
|
81
|
-
"@modern-js/server": "2.1.0",
|
|
82
|
-
"@modern-js/types": "2.1.0",
|
|
83
|
-
"@modern-js/upgrade": "2.1.0",
|
|
84
|
-
"@modern-js/utils": "2.1.0"
|
|
84
|
+
"esbuild": "0.15.7"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
|
+
"@modern-js/builder-plugin-swc": "2.2.0",
|
|
88
|
+
"@modern-js/server-core": "2.2.0",
|
|
89
|
+
"@scripts/build": "2.2.0",
|
|
90
|
+
"@scripts/jest-config": "2.2.0",
|
|
87
91
|
"@types/babel__traverse": "^7.14.2",
|
|
88
92
|
"@types/jest": "^27",
|
|
89
93
|
"@types/node": "^14",
|
|
90
94
|
"jest": "^27",
|
|
91
95
|
"typescript": "^4",
|
|
92
|
-
"webpack": "^5.75.0"
|
|
93
|
-
"@modern-js/builder-plugin-swc": "2.1.0",
|
|
94
|
-
"@modern-js/server-core": "2.1.0",
|
|
95
|
-
"@scripts/build": "2.1.0",
|
|
96
|
-
"@scripts/jest-config": "2.1.0"
|
|
96
|
+
"webpack": "^5.75.0"
|
|
97
97
|
},
|
|
98
98
|
"sideEffects": false,
|
|
99
99
|
"publishConfig": {
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
const getCommand = () => {
|
|
2
|
-
const args = process.argv.slice(2);
|
|
3
|
-
const command = args[0];
|
|
4
|
-
return command;
|
|
5
|
-
};
|
|
6
|
-
const isDevCommand = () => {
|
|
7
|
-
const command = getCommand();
|
|
8
|
-
return command === "dev" || command === "start";
|
|
9
|
-
};
|
|
10
|
-
export {
|
|
11
|
-
getCommand,
|
|
12
|
-
isDevCommand
|
|
13
|
-
};
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
var __async = (__this, __arguments, generator) => {
|
|
2
|
-
return new Promise((resolve, reject) => {
|
|
3
|
-
var fulfilled = (value) => {
|
|
4
|
-
try {
|
|
5
|
-
step(generator.next(value));
|
|
6
|
-
} catch (e) {
|
|
7
|
-
reject(e);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
var rejected = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
step(generator.throw(value));
|
|
13
|
-
} catch (e) {
|
|
14
|
-
reject(e);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
import crypto from "crypto";
|
|
22
|
-
import fs from "fs";
|
|
23
|
-
import path from "path";
|
|
24
|
-
import {
|
|
25
|
-
isDev,
|
|
26
|
-
chokidar,
|
|
27
|
-
createDebugger,
|
|
28
|
-
isTest,
|
|
29
|
-
getServerConfig
|
|
30
|
-
} from "@modern-js/utils";
|
|
31
|
-
const getPackageConfig = (appDirectory, packageJsonConfig) => {
|
|
32
|
-
const PACKAGE_JSON_CONFIG_NAME = "modernConfig";
|
|
33
|
-
const json = JSON.parse(
|
|
34
|
-
fs.readFileSync(path.resolve(appDirectory, "./package.json"), "utf8")
|
|
35
|
-
);
|
|
36
|
-
return json[packageJsonConfig != null ? packageJsonConfig : PACKAGE_JSON_CONFIG_NAME];
|
|
37
|
-
};
|
|
38
|
-
const addServerConfigToDeps = (dependencies, appDirectory, serverConfigFile) => __async(void 0, null, function* () {
|
|
39
|
-
const serverConfig = yield getServerConfig(appDirectory, serverConfigFile);
|
|
40
|
-
if (serverConfig) {
|
|
41
|
-
dependencies.push(serverConfig);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
const debug = createDebugger("watch-files");
|
|
45
|
-
const md5 = (data) => crypto.createHash("md5").update(data).digest("hex");
|
|
46
|
-
const hashMap = /* @__PURE__ */ new Map();
|
|
47
|
-
const createFileWatcher = (appContext, configDir, hooksRunner) => __async(void 0, null, function* () {
|
|
48
|
-
if (isDev() || isTest()) {
|
|
49
|
-
const { appDirectory, configFile } = appContext;
|
|
50
|
-
const extraFiles = yield hooksRunner.watchFiles();
|
|
51
|
-
const configPath = path.join(appDirectory, configDir);
|
|
52
|
-
const dependencies = getPackageConfig(
|
|
53
|
-
appContext.appDirectory,
|
|
54
|
-
appContext.packageName
|
|
55
|
-
) ? [path.resolve(appDirectory, "./package.json")] : [];
|
|
56
|
-
yield addServerConfigToDeps(
|
|
57
|
-
dependencies,
|
|
58
|
-
appContext.appDirectory,
|
|
59
|
-
appContext.serverConfigFile
|
|
60
|
-
);
|
|
61
|
-
const watched = [
|
|
62
|
-
`${configPath}/html`,
|
|
63
|
-
...extraFiles,
|
|
64
|
-
...dependencies,
|
|
65
|
-
configFile
|
|
66
|
-
].filter(Boolean);
|
|
67
|
-
debug(`watched: %o`, watched);
|
|
68
|
-
const watcher = chokidar.watch(watched, {
|
|
69
|
-
cwd: appDirectory,
|
|
70
|
-
ignoreInitial: true,
|
|
71
|
-
ignorePermissionErrors: true,
|
|
72
|
-
ignored: [
|
|
73
|
-
/node_modules/,
|
|
74
|
-
"**/__test__/**",
|
|
75
|
-
"**/*.test.(js|jsx|ts|tsx)",
|
|
76
|
-
"**/*.spec.(js|jsx|ts|tsx)",
|
|
77
|
-
"**/*.stories.(js|jsx|ts|tsx)"
|
|
78
|
-
]
|
|
79
|
-
});
|
|
80
|
-
watcher.on("change", (changed) => {
|
|
81
|
-
const lastHash = hashMap.get(changed);
|
|
82
|
-
const currentHash = md5(
|
|
83
|
-
fs.readFileSync(path.join(appDirectory, changed), "utf8")
|
|
84
|
-
);
|
|
85
|
-
if (currentHash !== lastHash) {
|
|
86
|
-
debug(`file change: %s`, changed);
|
|
87
|
-
hashMap.set(changed, currentHash);
|
|
88
|
-
hooksRunner.fileChange({ filename: changed, eventType: "change" });
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
watcher.on("add", (name) => {
|
|
92
|
-
debug(`add file: %s`, name);
|
|
93
|
-
const currentHash = md5(
|
|
94
|
-
fs.readFileSync(path.join(appDirectory, name), "utf8")
|
|
95
|
-
);
|
|
96
|
-
hashMap.set(name, currentHash);
|
|
97
|
-
hooksRunner.fileChange({ filename: name, eventType: "add" });
|
|
98
|
-
});
|
|
99
|
-
watcher.on("unlink", (name) => {
|
|
100
|
-
debug(`remove file: %s`, name);
|
|
101
|
-
if (hashMap.has(name)) {
|
|
102
|
-
hashMap.delete(name);
|
|
103
|
-
}
|
|
104
|
-
hooksRunner.fileChange({ filename: name, eventType: "unlink" });
|
|
105
|
-
});
|
|
106
|
-
watcher.on("error", (err) => {
|
|
107
|
-
throw err;
|
|
108
|
-
});
|
|
109
|
-
return watcher;
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
export {
|
|
113
|
-
addServerConfigToDeps,
|
|
114
|
-
createFileWatcher
|
|
115
|
-
};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var commands_exports = {};
|
|
19
|
-
__export(commands_exports, {
|
|
20
|
-
getCommand: () => getCommand,
|
|
21
|
-
isDevCommand: () => isDevCommand
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(commands_exports);
|
|
24
|
-
const getCommand = () => {
|
|
25
|
-
const args = process.argv.slice(2);
|
|
26
|
-
const command = args[0];
|
|
27
|
-
return command;
|
|
28
|
-
};
|
|
29
|
-
const isDevCommand = () => {
|
|
30
|
-
const command = getCommand();
|
|
31
|
-
return command === "dev" || command === "start";
|
|
32
|
-
};
|
|
33
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
-
0 && (module.exports = {
|
|
35
|
-
getCommand,
|
|
36
|
-
isDevCommand
|
|
37
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
var getCommand = function() {
|
|
2
|
-
var args = process.argv.slice(2);
|
|
3
|
-
var command = args[0];
|
|
4
|
-
return command;
|
|
5
|
-
};
|
|
6
|
-
var isDevCommand = function() {
|
|
7
|
-
var command = getCommand();
|
|
8
|
-
return command === "dev" || command === "start";
|
|
9
|
-
};
|
|
10
|
-
export { getCommand, isDevCommand };
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { IAppContext, ToRunners } from '@modern-js/core';
|
|
2
|
-
import { AppToolsHooks } from '../types/hooks';
|
|
3
|
-
export declare const addServerConfigToDeps: (dependencies: string[], appDirectory: string, serverConfigFile: string) => Promise<void>;
|
|
4
|
-
export declare const createFileWatcher: (appContext: IAppContext, configDir: string | undefined, hooksRunner: ToRunners<AppToolsHooks>) => Promise<import("@modern-js/utils").FSWatcher | undefined>;
|