@modern-js/app-tools 2.49.3-alpha.15 → 2.49.3-alpha.16
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/dist/cjs/plugins/deploy/dependencies.js +1 -11
- package/dist/cjs/plugins/deploy/index.js +6 -1
- package/dist/cjs/plugins/deploy/platforms/node.js +4 -1
- package/dist/cjs/plugins/deploy/utils.js +12 -0
- package/dist/esm/plugins/deploy/dependencies.js +1 -46
- package/dist/esm/plugins/deploy/index.js +6 -1
- package/dist/esm/plugins/deploy/platforms/node.js +6 -1
- package/dist/esm/plugins/deploy/utils.js +46 -0
- package/dist/esm-node/plugins/deploy/dependencies.js +1 -11
- package/dist/esm-node/plugins/deploy/index.js +6 -1
- package/dist/esm-node/plugins/deploy/platforms/node.js +4 -1
- package/dist/esm-node/plugins/deploy/utils.js +11 -0
- package/dist/types/plugins/deploy/utils.d.ts +1 -0
- package/package.json +8 -8
|
@@ -37,16 +37,6 @@ var import_utils = require("@modern-js/utils");
|
|
|
37
37
|
var import_pkg_types = require("pkg-types");
|
|
38
38
|
var import_mlly = require("mlly");
|
|
39
39
|
var import_utils2 = require("./utils");
|
|
40
|
-
const readDirRecursive = async (dir) => {
|
|
41
|
-
const files = await import_utils.fs.readdir(dir, {
|
|
42
|
-
withFileTypes: true
|
|
43
|
-
});
|
|
44
|
-
const filesAndDirs = await Promise.all(files.map(async (file) => {
|
|
45
|
-
const resPath = import_node_path.default.resolve(dir, file.name);
|
|
46
|
-
return file.isDirectory() ? readDirRecursive(resPath) : resPath;
|
|
47
|
-
}));
|
|
48
|
-
return filesAndDirs.flat();
|
|
49
|
-
};
|
|
50
40
|
async function isFile(file) {
|
|
51
41
|
try {
|
|
52
42
|
const stat = await import_utils.fs.stat(file);
|
|
@@ -59,7 +49,7 @@ async function isFile(file) {
|
|
|
59
49
|
}
|
|
60
50
|
}
|
|
61
51
|
const findEntryFiles = async (rootDir) => {
|
|
62
|
-
const files = await readDirRecursive(rootDir);
|
|
52
|
+
const files = await (0, import_utils2.readDirRecursive)(rootDir);
|
|
63
53
|
return files;
|
|
64
54
|
};
|
|
65
55
|
const handleDependencies = async (appDir, serverRootDir, include) => {
|
|
@@ -24,6 +24,8 @@ module.exports = __toCommonJS(deploy_exports);
|
|
|
24
24
|
var import_std_env = require("std-env");
|
|
25
25
|
var import_utils = require("./utils");
|
|
26
26
|
var import_node = require("./platforms/node");
|
|
27
|
+
var import_vercel = require("./platforms/vercel");
|
|
28
|
+
var import_netlify = require("./platforms/netlify");
|
|
27
29
|
var deploy_default = () => ({
|
|
28
30
|
name: "@modern-js/plugin-deploy",
|
|
29
31
|
pre: [
|
|
@@ -45,7 +47,10 @@ var deploy_default = () => ({
|
|
|
45
47
|
deployPreset = (0, import_node.createNodePreset)(appContext, modernConfig, needModernServer);
|
|
46
48
|
break;
|
|
47
49
|
case "vercel":
|
|
48
|
-
deployPreset = (0,
|
|
50
|
+
deployPreset = (0, import_vercel.createVercelPreset)(appContext, modernConfig, needModernServer);
|
|
51
|
+
break;
|
|
52
|
+
case "netlify":
|
|
53
|
+
deployPreset = (0, import_netlify.createNetlifyPreset)(appContext, modernConfig, needModernServer);
|
|
49
54
|
break;
|
|
50
55
|
default: {
|
|
51
56
|
throw new Error("unknown deploy target, MODERNJS_DEPLOY should be set");
|
|
@@ -35,7 +35,7 @@ var import_node_path = __toESM(require("node:path"));
|
|
|
35
35
|
var import_utils = require("@modern-js/utils");
|
|
36
36
|
var import_utils2 = require("../utils");
|
|
37
37
|
var import_dependencies = require("../dependencies");
|
|
38
|
-
const createNodePreset = (appContext, config) => {
|
|
38
|
+
const createNodePreset = (appContext, config, needModernServer) => {
|
|
39
39
|
const { appDirectory, distDirectory, serverInternalPlugins, sharedDirectory, apiDirectory, lambdaDirectory, metaName, entrypoints } = appContext;
|
|
40
40
|
const plugins = (0, import_utils.getInternalPlugins)(appDirectory, serverInternalPlugins);
|
|
41
41
|
const outputDirectory = import_node_path.default.join(appDirectory, ".output");
|
|
@@ -49,6 +49,9 @@ const createNodePreset = (appContext, config) => {
|
|
|
49
49
|
},
|
|
50
50
|
async genEntry() {
|
|
51
51
|
var _config_bff;
|
|
52
|
+
if (!needModernServer) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
52
55
|
const serverConfig = {
|
|
53
56
|
server: {
|
|
54
57
|
port: 8080
|
|
@@ -34,6 +34,7 @@ __export(utils_exports, {
|
|
|
34
34
|
getPluginsCode: () => getPluginsCode,
|
|
35
35
|
getProjectUsage: () => getProjectUsage,
|
|
36
36
|
linkPackage: () => linkPackage,
|
|
37
|
+
readDirRecursive: () => readDirRecursive,
|
|
37
38
|
serverAppContenxtTemplate: () => serverAppContenxtTemplate,
|
|
38
39
|
writePackage: () => writePackage
|
|
39
40
|
});
|
|
@@ -139,6 +140,16 @@ const linkPackage = async (from, to, projectRootDir) => {
|
|
|
139
140
|
console.error("Cannot link", from, "to", to, error);
|
|
140
141
|
});
|
|
141
142
|
};
|
|
143
|
+
const readDirRecursive = async (dir) => {
|
|
144
|
+
const files = await import_utils.fs.readdir(dir, {
|
|
145
|
+
withFileTypes: true
|
|
146
|
+
});
|
|
147
|
+
const filesAndDirs = await Promise.all(files.map(async (file) => {
|
|
148
|
+
const resPath = import_path.default.resolve(dir, file.name);
|
|
149
|
+
return file.isDirectory() ? readDirRecursive(resPath) : resPath;
|
|
150
|
+
}));
|
|
151
|
+
return filesAndDirs.flat();
|
|
152
|
+
};
|
|
142
153
|
// Annotate the CommonJS export names for ESM import in node:
|
|
143
154
|
0 && (module.exports = {
|
|
144
155
|
applyProductionCondition,
|
|
@@ -147,6 +158,7 @@ const linkPackage = async (from, to, projectRootDir) => {
|
|
|
147
158
|
getPluginsCode,
|
|
148
159
|
getProjectUsage,
|
|
149
160
|
linkPackage,
|
|
161
|
+
readDirRecursive,
|
|
150
162
|
serverAppContenxtTemplate,
|
|
151
163
|
writePackage
|
|
152
164
|
});
|
|
@@ -8,52 +8,7 @@ import { nodeFileTrace, resolve } from "@vercel/nft";
|
|
|
8
8
|
import { fs as fse, pkgUp, semver } from "@modern-js/utils";
|
|
9
9
|
import { readPackageJSON } from "pkg-types";
|
|
10
10
|
import { parseNodeModulePath } from "mlly";
|
|
11
|
-
import { linkPackage, writePackage } from "./utils";
|
|
12
|
-
var readDirRecursive = function() {
|
|
13
|
-
var _ref = _async_to_generator(function(dir) {
|
|
14
|
-
var files, filesAndDirs;
|
|
15
|
-
return _ts_generator(this, function(_state) {
|
|
16
|
-
switch (_state.label) {
|
|
17
|
-
case 0:
|
|
18
|
-
return [
|
|
19
|
-
4,
|
|
20
|
-
fse.readdir(dir, {
|
|
21
|
-
withFileTypes: true
|
|
22
|
-
})
|
|
23
|
-
];
|
|
24
|
-
case 1:
|
|
25
|
-
files = _state.sent();
|
|
26
|
-
return [
|
|
27
|
-
4,
|
|
28
|
-
Promise.all(files.map(function() {
|
|
29
|
-
var _ref2 = _async_to_generator(function(file) {
|
|
30
|
-
var resPath;
|
|
31
|
-
return _ts_generator(this, function(_state2) {
|
|
32
|
-
resPath = path.resolve(dir, file.name);
|
|
33
|
-
return [
|
|
34
|
-
2,
|
|
35
|
-
file.isDirectory() ? readDirRecursive(resPath) : resPath
|
|
36
|
-
];
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
return function(file) {
|
|
40
|
-
return _ref2.apply(this, arguments);
|
|
41
|
-
};
|
|
42
|
-
}()))
|
|
43
|
-
];
|
|
44
|
-
case 2:
|
|
45
|
-
filesAndDirs = _state.sent();
|
|
46
|
-
return [
|
|
47
|
-
2,
|
|
48
|
-
filesAndDirs.flat()
|
|
49
|
-
];
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
return function readDirRecursive2(dir) {
|
|
54
|
-
return _ref.apply(this, arguments);
|
|
55
|
-
};
|
|
56
|
-
}();
|
|
11
|
+
import { linkPackage, readDirRecursive, writePackage } from "./utils";
|
|
57
12
|
function isFile(file) {
|
|
58
13
|
return _isFile.apply(this, arguments);
|
|
59
14
|
}
|
|
@@ -3,6 +3,8 @@ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
|
3
3
|
import { provider } from "std-env";
|
|
4
4
|
import { getProjectUsage } from "./utils";
|
|
5
5
|
import { createNodePreset } from "./platforms/node";
|
|
6
|
+
import { createVercelPreset } from "./platforms/vercel";
|
|
7
|
+
import { createNetlifyPreset } from "./platforms/netlify";
|
|
6
8
|
function deploy_default() {
|
|
7
9
|
return {
|
|
8
10
|
name: "@modern-js/plugin-deploy",
|
|
@@ -29,7 +31,10 @@ function deploy_default() {
|
|
|
29
31
|
deployPreset = createNodePreset(appContext, modernConfig, needModernServer);
|
|
30
32
|
break;
|
|
31
33
|
case "vercel":
|
|
32
|
-
deployPreset =
|
|
34
|
+
deployPreset = createVercelPreset(appContext, modernConfig, needModernServer);
|
|
35
|
+
break;
|
|
36
|
+
case "netlify":
|
|
37
|
+
deployPreset = createNetlifyPreset(appContext, modernConfig, needModernServer);
|
|
33
38
|
break;
|
|
34
39
|
default: {
|
|
35
40
|
throw new Error("unknown deploy target, MODERNJS_DEPLOY should be set");
|
|
@@ -4,7 +4,7 @@ import path from "node:path";
|
|
|
4
4
|
import { ROUTE_SPEC_FILE, DEFAULT_SERVER_CONFIG, fs as fse, getInternalPlugins } from "@modern-js/utils";
|
|
5
5
|
import { genPluginImportsCode, serverAppContenxtTemplate } from "../utils";
|
|
6
6
|
import { handleDependencies } from "../dependencies";
|
|
7
|
-
var createNodePreset = function(appContext, config) {
|
|
7
|
+
var createNodePreset = function(appContext, config, needModernServer) {
|
|
8
8
|
var appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory, serverInternalPlugins = appContext.serverInternalPlugins, sharedDirectory = appContext.sharedDirectory, apiDirectory = appContext.apiDirectory, lambdaDirectory = appContext.lambdaDirectory, metaName = appContext.metaName, entrypoints = appContext.entrypoints;
|
|
9
9
|
var plugins = getInternalPlugins(appDirectory, serverInternalPlugins);
|
|
10
10
|
var outputDirectory = path.join(appDirectory, ".output");
|
|
@@ -52,6 +52,11 @@ var createNodePreset = function(appContext, config) {
|
|
|
52
52
|
return _ts_generator(this, function(_state) {
|
|
53
53
|
switch (_state.label) {
|
|
54
54
|
case 0:
|
|
55
|
+
if (!needModernServer) {
|
|
56
|
+
return [
|
|
57
|
+
2
|
|
58
|
+
];
|
|
59
|
+
}
|
|
55
60
|
serverConfig = {
|
|
56
61
|
server: {
|
|
57
62
|
port: 8080
|
|
@@ -238,6 +238,51 @@ var linkPackage = function() {
|
|
|
238
238
|
return _ref.apply(this, arguments);
|
|
239
239
|
};
|
|
240
240
|
}();
|
|
241
|
+
var readDirRecursive = function() {
|
|
242
|
+
var _ref = _async_to_generator(function(dir) {
|
|
243
|
+
var files, filesAndDirs;
|
|
244
|
+
return _ts_generator(this, function(_state) {
|
|
245
|
+
switch (_state.label) {
|
|
246
|
+
case 0:
|
|
247
|
+
return [
|
|
248
|
+
4,
|
|
249
|
+
fse.readdir(dir, {
|
|
250
|
+
withFileTypes: true
|
|
251
|
+
})
|
|
252
|
+
];
|
|
253
|
+
case 1:
|
|
254
|
+
files = _state.sent();
|
|
255
|
+
return [
|
|
256
|
+
4,
|
|
257
|
+
Promise.all(files.map(function() {
|
|
258
|
+
var _ref2 = _async_to_generator(function(file) {
|
|
259
|
+
var resPath;
|
|
260
|
+
return _ts_generator(this, function(_state2) {
|
|
261
|
+
resPath = path.resolve(dir, file.name);
|
|
262
|
+
return [
|
|
263
|
+
2,
|
|
264
|
+
file.isDirectory() ? readDirRecursive(resPath) : resPath
|
|
265
|
+
];
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
return function(file) {
|
|
269
|
+
return _ref2.apply(this, arguments);
|
|
270
|
+
};
|
|
271
|
+
}()))
|
|
272
|
+
];
|
|
273
|
+
case 2:
|
|
274
|
+
filesAndDirs = _state.sent();
|
|
275
|
+
return [
|
|
276
|
+
2,
|
|
277
|
+
filesAndDirs.flat()
|
|
278
|
+
];
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
return function readDirRecursive2(dir) {
|
|
283
|
+
return _ref.apply(this, arguments);
|
|
284
|
+
};
|
|
285
|
+
}();
|
|
241
286
|
export {
|
|
242
287
|
applyProductionCondition,
|
|
243
288
|
applyPublicCondition,
|
|
@@ -245,6 +290,7 @@ export {
|
|
|
245
290
|
getPluginsCode,
|
|
246
291
|
getProjectUsage,
|
|
247
292
|
linkPackage,
|
|
293
|
+
readDirRecursive,
|
|
248
294
|
serverAppContenxtTemplate,
|
|
249
295
|
writePackage
|
|
250
296
|
};
|
|
@@ -3,17 +3,7 @@ import { nodeFileTrace, resolve } from "@vercel/nft";
|
|
|
3
3
|
import { fs as fse, pkgUp, semver } from "@modern-js/utils";
|
|
4
4
|
import { readPackageJSON } from "pkg-types";
|
|
5
5
|
import { parseNodeModulePath } from "mlly";
|
|
6
|
-
import { linkPackage, writePackage } from "./utils";
|
|
7
|
-
const readDirRecursive = async (dir) => {
|
|
8
|
-
const files = await fse.readdir(dir, {
|
|
9
|
-
withFileTypes: true
|
|
10
|
-
});
|
|
11
|
-
const filesAndDirs = await Promise.all(files.map(async (file) => {
|
|
12
|
-
const resPath = path.resolve(dir, file.name);
|
|
13
|
-
return file.isDirectory() ? readDirRecursive(resPath) : resPath;
|
|
14
|
-
}));
|
|
15
|
-
return filesAndDirs.flat();
|
|
16
|
-
};
|
|
6
|
+
import { linkPackage, readDirRecursive, writePackage } from "./utils";
|
|
17
7
|
async function isFile(file) {
|
|
18
8
|
try {
|
|
19
9
|
const stat = await fse.stat(file);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { provider } from "std-env";
|
|
2
2
|
import { getProjectUsage } from "./utils";
|
|
3
3
|
import { createNodePreset } from "./platforms/node";
|
|
4
|
+
import { createVercelPreset } from "./platforms/vercel";
|
|
5
|
+
import { createNetlifyPreset } from "./platforms/netlify";
|
|
4
6
|
var deploy_default = () => ({
|
|
5
7
|
name: "@modern-js/plugin-deploy",
|
|
6
8
|
pre: [
|
|
@@ -22,7 +24,10 @@ var deploy_default = () => ({
|
|
|
22
24
|
deployPreset = createNodePreset(appContext, modernConfig, needModernServer);
|
|
23
25
|
break;
|
|
24
26
|
case "vercel":
|
|
25
|
-
deployPreset =
|
|
27
|
+
deployPreset = createVercelPreset(appContext, modernConfig, needModernServer);
|
|
28
|
+
break;
|
|
29
|
+
case "netlify":
|
|
30
|
+
deployPreset = createNetlifyPreset(appContext, modernConfig, needModernServer);
|
|
26
31
|
break;
|
|
27
32
|
default: {
|
|
28
33
|
throw new Error("unknown deploy target, MODERNJS_DEPLOY should be set");
|
|
@@ -2,7 +2,7 @@ import path from "node:path";
|
|
|
2
2
|
import { ROUTE_SPEC_FILE, DEFAULT_SERVER_CONFIG, fs as fse, getInternalPlugins } from "@modern-js/utils";
|
|
3
3
|
import { genPluginImportsCode, serverAppContenxtTemplate } from "../utils";
|
|
4
4
|
import { handleDependencies } from "../dependencies";
|
|
5
|
-
const createNodePreset = (appContext, config) => {
|
|
5
|
+
const createNodePreset = (appContext, config, needModernServer) => {
|
|
6
6
|
const { appDirectory, distDirectory, serverInternalPlugins, sharedDirectory, apiDirectory, lambdaDirectory, metaName, entrypoints } = appContext;
|
|
7
7
|
const plugins = getInternalPlugins(appDirectory, serverInternalPlugins);
|
|
8
8
|
const outputDirectory = path.join(appDirectory, ".output");
|
|
@@ -16,6 +16,9 @@ const createNodePreset = (appContext, config) => {
|
|
|
16
16
|
},
|
|
17
17
|
async genEntry() {
|
|
18
18
|
var _config_bff;
|
|
19
|
+
if (!needModernServer) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
19
22
|
const serverConfig = {
|
|
20
23
|
server: {
|
|
21
24
|
port: 8080
|
|
@@ -99,6 +99,16 @@ const linkPackage = async (from, to, projectRootDir) => {
|
|
|
99
99
|
console.error("Cannot link", from, "to", to, error);
|
|
100
100
|
});
|
|
101
101
|
};
|
|
102
|
+
const readDirRecursive = async (dir) => {
|
|
103
|
+
const files = await fse.readdir(dir, {
|
|
104
|
+
withFileTypes: true
|
|
105
|
+
});
|
|
106
|
+
const filesAndDirs = await Promise.all(files.map(async (file) => {
|
|
107
|
+
const resPath = path.resolve(dir, file.name);
|
|
108
|
+
return file.isDirectory() ? readDirRecursive(resPath) : resPath;
|
|
109
|
+
}));
|
|
110
|
+
return filesAndDirs.flat();
|
|
111
|
+
};
|
|
102
112
|
export {
|
|
103
113
|
applyProductionCondition,
|
|
104
114
|
applyPublicCondition,
|
|
@@ -106,6 +116,7 @@ export {
|
|
|
106
116
|
getPluginsCode,
|
|
107
117
|
getProjectUsage,
|
|
108
118
|
linkPackage,
|
|
119
|
+
readDirRecursive,
|
|
109
120
|
serverAppContenxtTemplate,
|
|
110
121
|
writePackage
|
|
111
122
|
};
|
|
@@ -31,3 +31,4 @@ export type TracedPackage = {
|
|
|
31
31
|
};
|
|
32
32
|
export declare const writePackage: (pkg: TracedPackage, version: string, projectDir: string, _pkgPath?: string) => Promise<void>;
|
|
33
33
|
export declare const linkPackage: (from: string, to: string, projectRootDir: string) => Promise<void>;
|
|
34
|
+
export declare const readDirRecursive: (dir: string) => Promise<string[]>;
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.49.3-alpha.
|
|
18
|
+
"version": "2.49.3-alpha.16",
|
|
19
19
|
"jsnext:source": "./src/index.ts",
|
|
20
20
|
"types": "./dist/types/index.d.ts",
|
|
21
21
|
"main": "./dist/cjs/index.js",
|
|
@@ -80,20 +80,20 @@
|
|
|
80
80
|
"mlly": "^1.6.1",
|
|
81
81
|
"pkg-types": "^1.1.0",
|
|
82
82
|
"std-env": "^3.7.0",
|
|
83
|
+
"@modern-js/plugin-data-loader": "2.49.2",
|
|
83
84
|
"@modern-js/core": "2.49.2",
|
|
84
85
|
"@modern-js/plugin": "2.49.2",
|
|
85
|
-
"@modern-js/prod-server": "2.49.2",
|
|
86
|
-
"@modern-js/node-bundle-require": "2.49.2",
|
|
87
|
-
"@modern-js/plugin-i18n": "2.49.2",
|
|
88
86
|
"@modern-js/plugin-lint": "2.49.2",
|
|
89
87
|
"@modern-js/rsbuild-plugin-esbuild": "2.49.2",
|
|
88
|
+
"@modern-js/prod-server": "2.49.2",
|
|
89
|
+
"@modern-js/plugin-i18n": "2.49.2",
|
|
90
90
|
"@modern-js/server-core": "2.49.2",
|
|
91
|
-
"@modern-js/
|
|
91
|
+
"@modern-js/node-bundle-require": "2.49.2",
|
|
92
92
|
"@modern-js/server-utils": "2.49.2",
|
|
93
|
-
"@modern-js/uni-builder": "2.49.2",
|
|
94
|
-
"@modern-js/utils": "2.49.2",
|
|
95
93
|
"@modern-js/types": "2.49.2",
|
|
96
|
-
"@modern-js/
|
|
94
|
+
"@modern-js/utils": "2.49.2",
|
|
95
|
+
"@modern-js/uni-builder": "2.49.2",
|
|
96
|
+
"@modern-js/server": "2.49.2"
|
|
97
97
|
},
|
|
98
98
|
"devDependencies": {
|
|
99
99
|
"@rsbuild/plugin-swc": "0.6.10",
|