@modern-js/ssg-generator 3.0.4 → 3.0.5
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/index.js +31 -10
- package/package.json +7 -7
- package/src/index.ts +75 -0
package/dist/index.js
CHANGED
@@ -35750,7 +35750,7 @@ var require_nodeEnv = __commonJS({
|
|
35750
35750
|
});
|
35751
35751
|
}
|
35752
35752
|
exports.canUseNpm = canUseNpm2;
|
35753
|
-
function
|
35753
|
+
function canUseYarn() {
|
35754
35754
|
return __async(this, null, function* () {
|
35755
35755
|
try {
|
35756
35756
|
yield (0, compiled_1.execa)("yarn", ["--version"], { env: process.env });
|
@@ -35760,7 +35760,7 @@ var require_nodeEnv = __commonJS({
|
|
35760
35760
|
}
|
35761
35761
|
});
|
35762
35762
|
}
|
35763
|
-
exports.canUseYarn =
|
35763
|
+
exports.canUseYarn = canUseYarn;
|
35764
35764
|
function canUsePnpm2() {
|
35765
35765
|
return __async(this, null, function* () {
|
35766
35766
|
try {
|
@@ -44398,7 +44398,7 @@ var require_env = __commonJS({
|
|
44398
44398
|
exports.canUseNpm = canUseNpm2;
|
44399
44399
|
exports.canUseNvm = canUseNvm;
|
44400
44400
|
exports.canUsePnpm = canUsePnpm2;
|
44401
|
-
exports.canUseYarn =
|
44401
|
+
exports.canUseYarn = canUseYarn;
|
44402
44402
|
var _utils = require_dist();
|
44403
44403
|
function canUseNvm() {
|
44404
44404
|
return __async(this, null, function* () {
|
@@ -44425,7 +44425,7 @@ var require_env = __commonJS({
|
|
44425
44425
|
}
|
44426
44426
|
});
|
44427
44427
|
}
|
44428
|
-
function
|
44428
|
+
function canUseYarn() {
|
44429
44429
|
return __async(this, null, function* () {
|
44430
44430
|
try {
|
44431
44431
|
yield (0, _utils.execa)("yarn", ["--version"], {
|
@@ -45461,14 +45461,14 @@ var require_packageManager = __commonJS({
|
|
45461
45461
|
value: true
|
45462
45462
|
});
|
45463
45463
|
exports.canUsePnpm = canUsePnpm2;
|
45464
|
-
exports.canUseYarn =
|
45464
|
+
exports.canUseYarn = canUseYarn;
|
45465
45465
|
exports.runInstall = runInstall;
|
45466
45466
|
var _path = _interopRequireDefault(require("path"));
|
45467
45467
|
var _utils = require_dist();
|
45468
45468
|
function _interopRequireDefault(obj) {
|
45469
45469
|
return obj && obj.__esModule ? obj : { default: obj };
|
45470
45470
|
}
|
45471
|
-
function
|
45471
|
+
function canUseYarn() {
|
45472
45472
|
return __async(this, null, function* () {
|
45473
45473
|
try {
|
45474
45474
|
yield (0, _utils.execa)("yarn", ["--version"], {
|
@@ -45515,7 +45515,7 @@ var require_packageManager = __commonJS({
|
|
45515
45515
|
params.push(`--registry=${registryUrl}`);
|
45516
45516
|
}
|
45517
45517
|
yield (0, _utils.execa)("pnpm", params, options);
|
45518
|
-
} else if (yield
|
45518
|
+
} else if (yield canUseYarn()) {
|
45519
45519
|
const params = ["install", "--production", "--silent", "--ignore-scripts"];
|
45520
45520
|
if (registryUrl) {
|
45521
45521
|
params.push(`--registry=${registryUrl}`);
|
@@ -133817,6 +133817,26 @@ var require_compiled2 = __commonJS({
|
|
133817
133817
|
}
|
133818
133818
|
});
|
133819
133819
|
|
133820
|
+
// ../../../toolkit/utils/dist/commands.js
|
133821
|
+
var require_commands = __commonJS({
|
133822
|
+
"../../../toolkit/utils/dist/commands.js"(exports) {
|
133823
|
+
"use strict";
|
133824
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
133825
|
+
exports.isDevCommand = exports.getCommand = void 0;
|
133826
|
+
var getCommand = () => {
|
133827
|
+
const args = process.argv.slice(2);
|
133828
|
+
const command = args[0];
|
133829
|
+
return command;
|
133830
|
+
};
|
133831
|
+
exports.getCommand = getCommand;
|
133832
|
+
var isDevCommand = () => {
|
133833
|
+
const command = (0, exports.getCommand)();
|
133834
|
+
return command === "dev" || command === "start";
|
133835
|
+
};
|
133836
|
+
exports.isDevCommand = isDevCommand;
|
133837
|
+
}
|
133838
|
+
});
|
133839
|
+
|
133820
133840
|
// ../../../toolkit/utils/dist/format.js
|
133821
133841
|
var require_format2 = __commonJS({
|
133822
133842
|
"../../../toolkit/utils/dist/format.js"(exports) {
|
@@ -134391,7 +134411,7 @@ var require_constants6 = __commonJS({
|
|
134391
134411
|
exports.SERVER_DIR = "server";
|
134392
134412
|
exports.SHARED_DIR = "shared";
|
134393
134413
|
exports.CONFIG_CACHE_DIR = "./node_modules/.cache/node-bundle-require";
|
134394
|
-
exports.CONFIG_FILE_EXTENSIONS = [".js", ".ts", ".
|
134414
|
+
exports.CONFIG_FILE_EXTENSIONS = [".js", ".ts", ".mjs"];
|
134395
134415
|
exports.OUTPUT_CONFIG_FILE = "modern.config.json";
|
134396
134416
|
exports.DEFAULT_SERVER_CONFIG = "modern.server-runtime.config";
|
134397
134417
|
exports.ROUTE_MINIFEST_FILE = "routes-manifest.json";
|
@@ -134882,7 +134902,7 @@ var require_nodeEnv2 = __commonJS({
|
|
134882
134902
|
});
|
134883
134903
|
}
|
134884
134904
|
exports.canUseNpm = canUseNpm2;
|
134885
|
-
function
|
134905
|
+
function canUseYarn() {
|
134886
134906
|
return __async(this, null, function* () {
|
134887
134907
|
try {
|
134888
134908
|
yield (0, compiled_1.execa)("yarn", ["--version"], { env: process.env });
|
@@ -134892,7 +134912,7 @@ var require_nodeEnv2 = __commonJS({
|
|
134892
134912
|
}
|
134893
134913
|
});
|
134894
134914
|
}
|
134895
|
-
exports.canUseYarn =
|
134915
|
+
exports.canUseYarn = canUseYarn;
|
134896
134916
|
function canUsePnpm2() {
|
134897
134917
|
return __async(this, null, function* () {
|
134898
134918
|
try {
|
@@ -135971,6 +135991,7 @@ var require_dist2 = __commonJS({
|
|
135971
135991
|
};
|
135972
135992
|
Object.defineProperty(exports, "__esModule", { value: true });
|
135973
135993
|
__exportStar(require_compiled2(), exports);
|
135994
|
+
__exportStar(require_commands(), exports);
|
135974
135995
|
__exportStar(require_format2(), exports);
|
135975
135996
|
__exportStar(require_FileSizeReporter2(), exports);
|
135976
135997
|
__exportStar(require_printBuildError2(), exports);
|
package/package.json
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"modern",
|
12
12
|
"modern.js"
|
13
13
|
],
|
14
|
-
"version": "3.0.
|
14
|
+
"version": "3.0.5",
|
15
15
|
"jsnext:source": "./src/index.ts",
|
16
16
|
"main": "./dist/index.js",
|
17
17
|
"files": [
|
@@ -26,12 +26,12 @@
|
|
26
26
|
"@types/node": "^14",
|
27
27
|
"jest": "^27",
|
28
28
|
"typescript": "^4",
|
29
|
-
"@modern-js/generator-
|
30
|
-
"@modern-js/generator-
|
31
|
-
"@modern-js/plugin-i18n": "2.
|
32
|
-
"@modern-js/dependence-generator": "3.0.
|
33
|
-
"@scripts/
|
34
|
-
"@scripts/
|
29
|
+
"@modern-js/generator-utils": "3.0.5",
|
30
|
+
"@modern-js/generator-common": "3.0.5",
|
31
|
+
"@modern-js/plugin-i18n": "2.3.0",
|
32
|
+
"@modern-js/dependence-generator": "3.0.5",
|
33
|
+
"@scripts/build": "2.3.0",
|
34
|
+
"@scripts/jest-config": "2.3.0"
|
35
35
|
},
|
36
36
|
"sideEffects": false,
|
37
37
|
"publishConfig": {
|
package/src/index.ts
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
import path from 'path';
|
2
|
+
import { GeneratorContext, GeneratorCore } from '@modern-js/codesmith';
|
3
|
+
import { AppAPI } from '@modern-js/codesmith-api-app';
|
4
|
+
import { getModernConfigFile } from '@modern-js/generator-utils';
|
5
|
+
import {
|
6
|
+
DependenceGenerator,
|
7
|
+
i18n as commonI18n,
|
8
|
+
} from '@modern-js/generator-common';
|
9
|
+
import { i18n, localeKeys } from './locale';
|
10
|
+
|
11
|
+
const getGeneratorPath = (generator: string, distTag: string) => {
|
12
|
+
if (process.env.CODESMITH_ENV === 'development') {
|
13
|
+
return path.dirname(require.resolve(generator));
|
14
|
+
} else if (distTag) {
|
15
|
+
return `${generator}@${distTag}`;
|
16
|
+
}
|
17
|
+
return generator;
|
18
|
+
};
|
19
|
+
|
20
|
+
const handleTemplateFile = async (
|
21
|
+
context: GeneratorContext,
|
22
|
+
generator: GeneratorCore,
|
23
|
+
appApi: AppAPI,
|
24
|
+
) => {
|
25
|
+
await appApi.runSubGenerator(
|
26
|
+
getGeneratorPath(DependenceGenerator, context.config.distTag),
|
27
|
+
undefined,
|
28
|
+
{
|
29
|
+
...context.config,
|
30
|
+
isSubGenerator: true,
|
31
|
+
},
|
32
|
+
);
|
33
|
+
};
|
34
|
+
|
35
|
+
export default async (context: GeneratorContext, generator: GeneratorCore) => {
|
36
|
+
const appApi = new AppAPI(context, generator);
|
37
|
+
|
38
|
+
const { locale } = context.config;
|
39
|
+
commonI18n.changeLanguage({ locale });
|
40
|
+
appApi.i18n.changeLanguage({ locale });
|
41
|
+
|
42
|
+
if (!(await appApi.checkEnvironment())) {
|
43
|
+
// eslint-disable-next-line no-process-exit
|
44
|
+
process.exit(1);
|
45
|
+
}
|
46
|
+
|
47
|
+
generator.logger.debug(`start run @modern-js/ssg-generator`);
|
48
|
+
generator.logger.debug(`context=${JSON.stringify(context)}`);
|
49
|
+
generator.logger.debug(`context.data=${JSON.stringify(context.data)}`);
|
50
|
+
|
51
|
+
await handleTemplateFile(context, generator, appApi);
|
52
|
+
|
53
|
+
if (!context.config.isSubGenerator) {
|
54
|
+
await appApi.runInstall(undefined, { ignoreScripts: true });
|
55
|
+
if (!context.config.pluginName) {
|
56
|
+
appApi.showSuccessInfo();
|
57
|
+
} else {
|
58
|
+
const appDir = context.materials.default.basePath;
|
59
|
+
const configFile = await getModernConfigFile(appDir);
|
60
|
+
appApi.showSuccessInfo(
|
61
|
+
i18n.t(
|
62
|
+
configFile.endsWith('ts')
|
63
|
+
? localeKeys.successTs
|
64
|
+
: localeKeys.successJS,
|
65
|
+
{
|
66
|
+
configFile,
|
67
|
+
pluginName: context.config.pluginName,
|
68
|
+
pluginDependence: context.config.pluginDependence,
|
69
|
+
},
|
70
|
+
),
|
71
|
+
);
|
72
|
+
}
|
73
|
+
}
|
74
|
+
generator.logger.debug(`forge @modern-js/ssg-generator succeed `);
|
75
|
+
};
|