@modern-js/generator-utils 3.0.0-beta.3 → 3.0.0-beta.4
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 +32 -0
- package/dist/js/modern/index.js +165 -108
- package/dist/js/modern/locale/en.js +7 -8
- package/dist/js/modern/locale/index.js +6 -6
- package/dist/js/modern/locale/zh.js +7 -8
- package/dist/js/modern/utils/index.js +1 -1
- package/dist/js/modern/utils/package.js +73 -55
- package/dist/js/modern/utils/strip-ansi.js +13 -9
- package/dist/js/node/index.js +167 -219
- package/dist/js/node/locale/en.js +23 -12
- package/dist/js/node/locale/index.js +27 -15
- package/dist/js/node/locale/zh.js +23 -12
- package/dist/js/node/utils/index.js +18 -27
- package/dist/js/node/utils/package.js +92 -63
- package/dist/js/node/utils/strip-ansi.js +30 -13
- package/dist/types/utils/package.d.ts +1 -0
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @modern-js/generator-utils
|
|
2
2
|
|
|
3
|
+
## 3.0.0-beta.4
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- dda38c9c3e: chore: v2
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [7879e8f]
|
|
12
|
+
- Updated dependencies [6aca875]
|
|
13
|
+
- Updated dependencies [2e6031955e]
|
|
14
|
+
- Updated dependencies [7b7d12c]
|
|
15
|
+
- Updated dependencies [92f0eade39]
|
|
16
|
+
- Updated dependencies [edd1cfb1af]
|
|
17
|
+
- Updated dependencies [cc971eabfc]
|
|
18
|
+
- Updated dependencies [5b9049f2e9]
|
|
19
|
+
- Updated dependencies [92004d1906]
|
|
20
|
+
- Updated dependencies [b8bbe036c7]
|
|
21
|
+
- Updated dependencies [d5a31df781]
|
|
22
|
+
- Updated dependencies [dda38c9c3e]
|
|
23
|
+
- Updated dependencies [3bbea92b2a]
|
|
24
|
+
- Updated dependencies [b710adb843]
|
|
25
|
+
- Updated dependencies [ea7cf06]
|
|
26
|
+
- Updated dependencies [bbe4c4a]
|
|
27
|
+
- Updated dependencies [e4558a0]
|
|
28
|
+
- Updated dependencies [abf3421a75]
|
|
29
|
+
- Updated dependencies [543be9558e]
|
|
30
|
+
- Updated dependencies [14b712da84]
|
|
31
|
+
- @modern-js/utils@2.0.0-beta.4
|
|
32
|
+
- @modern-js/plugin-i18n@2.0.0-beta.4
|
|
33
|
+
- @modern-js/generator-common@3.0.0-beta.4
|
|
34
|
+
|
|
3
35
|
## 3.0.0-beta.3
|
|
4
36
|
|
|
5
37
|
### Major Changes
|
package/dist/js/modern/index.js
CHANGED
|
@@ -1,148 +1,205 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 path from "path";
|
|
22
|
+
import {
|
|
23
|
+
fs,
|
|
24
|
+
ora,
|
|
25
|
+
execa,
|
|
26
|
+
getMonorepoPackages,
|
|
27
|
+
canUseNpm,
|
|
28
|
+
canUsePnpm,
|
|
29
|
+
canUseYarn
|
|
30
|
+
} from "@modern-js/utils";
|
|
31
|
+
import { SolutionToolsMap } from "@modern-js/generator-common";
|
|
4
32
|
import { stripAnsi } from "./utils/strip-ansi";
|
|
5
33
|
import { i18n, localeKeys } from "./locale";
|
|
6
34
|
import { getAvailableVersion } from "./utils/package";
|
|
7
35
|
export * from "./utils";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
36
|
+
import {
|
|
37
|
+
ora as ora2,
|
|
38
|
+
fs as fs2,
|
|
39
|
+
semver,
|
|
40
|
+
execa as execa2,
|
|
41
|
+
readTsConfigByFile,
|
|
42
|
+
getPackageManager,
|
|
43
|
+
canUseNpm as canUseNpm2,
|
|
44
|
+
canUsePnpm as canUsePnpm2,
|
|
45
|
+
canUseYarn as canUseYarn2,
|
|
46
|
+
isReact18
|
|
47
|
+
} from "@modern-js/utils";
|
|
48
|
+
import { i18n as i18n2 } from "./locale";
|
|
49
|
+
function getPackageVersion(packageName, registry) {
|
|
50
|
+
return __async(this, null, function* () {
|
|
51
|
+
const spinner = ora({
|
|
52
|
+
text: "Load Generator...",
|
|
53
|
+
spinner: "runner"
|
|
54
|
+
}).start();
|
|
55
|
+
if (yield canUsePnpm()) {
|
|
56
|
+
const args = ["info", packageName, "version"];
|
|
57
|
+
if (registry) {
|
|
58
|
+
args.push(`--registry=${registry}`);
|
|
59
|
+
}
|
|
60
|
+
const result = yield execa("pnpm", args);
|
|
61
|
+
spinner.stop();
|
|
62
|
+
return stripAnsi(result.stdout);
|
|
19
63
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
64
|
+
if (yield canUseYarn()) {
|
|
65
|
+
const args = ["info", packageName, "version", "--silent"];
|
|
66
|
+
if (registry) {
|
|
67
|
+
args.push(`--registry=${registry}`);
|
|
68
|
+
}
|
|
69
|
+
const result = yield execa("yarn", args);
|
|
70
|
+
spinner.stop();
|
|
71
|
+
return stripAnsi(result.stdout);
|
|
28
72
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
73
|
+
if (yield canUseNpm()) {
|
|
74
|
+
const args = ["view", packageName, "version"];
|
|
75
|
+
if (registry) {
|
|
76
|
+
args.push(`--registry=${registry}`);
|
|
77
|
+
}
|
|
78
|
+
const result = yield execa("npm", args);
|
|
79
|
+
spinner.stop();
|
|
80
|
+
return stripAnsi(result.stdout);
|
|
37
81
|
}
|
|
38
|
-
const result = await execa('npm', args);
|
|
39
82
|
spinner.stop();
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
spinner.stop();
|
|
43
|
-
throw new Error('not found npm, please install npm before');
|
|
83
|
+
throw new Error("not found npm, please install npm before");
|
|
84
|
+
});
|
|
44
85
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
86
|
+
function getModernVersion(solution, registry, distTag = "latest") {
|
|
87
|
+
return __async(this, null, function* () {
|
|
88
|
+
const dep = SolutionToolsMap[solution];
|
|
89
|
+
const modernVersion = yield getPackageVersion(`${dep}@${distTag}`, registry);
|
|
90
|
+
return modernVersion;
|
|
91
|
+
});
|
|
49
92
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
cwd = process.cwd(),
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
// get project solution version
|
|
66
|
-
const pkgPath = path.join(require.resolve(SolutionToolsMap[solution], {
|
|
67
|
-
paths: [cwd]
|
|
68
|
-
}), '../../../../', 'package.json');
|
|
69
|
-
if (fs.existsSync(pkgPath)) {
|
|
70
|
-
const pkgInfo = fs.readJSONSync(pkgPath);
|
|
71
|
-
const modernVersion = pkgInfo.version;
|
|
72
|
-
if (typeof modernVersion !== 'string') {
|
|
73
|
-
return getLatetPluginVersion();
|
|
93
|
+
function getModernPluginVersion(_0, _1) {
|
|
94
|
+
return __async(this, arguments, function* (solution, packageName, options = {
|
|
95
|
+
distTag: "latest"
|
|
96
|
+
}) {
|
|
97
|
+
const { cwd = process.cwd(), registry, distTag } = options;
|
|
98
|
+
const getLatetPluginVersion = (tag) => __async(this, null, function* () {
|
|
99
|
+
const version = yield getPackageVersion(
|
|
100
|
+
`${packageName}@${tag || distTag || "latest"}`,
|
|
101
|
+
registry
|
|
102
|
+
);
|
|
103
|
+
return version;
|
|
104
|
+
});
|
|
105
|
+
if (!packageName.startsWith("@modern-js") || packageName.includes("electron") || packageName.includes("codesmith") || packageName.includes("easy-form") || packageName.startsWith("@modern-js-reduck")) {
|
|
106
|
+
return getLatetPluginVersion("latest");
|
|
74
107
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
108
|
+
const pkgPath = path.join(
|
|
109
|
+
require.resolve(SolutionToolsMap[solution], { paths: [cwd] }),
|
|
110
|
+
"../../../../",
|
|
111
|
+
"package.json"
|
|
112
|
+
);
|
|
113
|
+
if (fs.existsSync(pkgPath)) {
|
|
114
|
+
const pkgInfo = fs.readJSONSync(pkgPath);
|
|
115
|
+
const modernVersion = pkgInfo.version;
|
|
116
|
+
if (typeof modernVersion !== "string") {
|
|
117
|
+
return getLatetPluginVersion();
|
|
118
|
+
}
|
|
119
|
+
return getAvailableVersion(packageName, modernVersion, registry);
|
|
120
|
+
}
|
|
121
|
+
return getLatetPluginVersion();
|
|
122
|
+
});
|
|
78
123
|
}
|
|
79
|
-
|
|
80
|
-
return packageManager ===
|
|
124
|
+
function getPackageManagerText(packageManager) {
|
|
125
|
+
return packageManager === "yarn" ? "yarn" : `${packageManager} run`;
|
|
81
126
|
}
|
|
82
|
-
|
|
83
|
-
return fs.existsSync(path.join(appDir,
|
|
127
|
+
function isTsProject(appDir) {
|
|
128
|
+
return fs.existsSync(path.join(appDir, "tsconfig.json"));
|
|
84
129
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
130
|
+
function getPackageObj(context) {
|
|
131
|
+
return __async(this, null, function* () {
|
|
132
|
+
const pkgStr = (yield context.materials.default.get(`package.json`).value()).content;
|
|
133
|
+
return JSON.parse(pkgStr);
|
|
134
|
+
});
|
|
88
135
|
}
|
|
89
|
-
|
|
136
|
+
function getAllPackages(appDir) {
|
|
90
137
|
const packages = getMonorepoPackages(appDir);
|
|
91
|
-
return packages.map(pkg => pkg.name);
|
|
138
|
+
return packages.map((pkg) => pkg.name);
|
|
92
139
|
}
|
|
93
|
-
|
|
94
|
-
const {
|
|
95
|
-
isMonorepoSubProject
|
|
96
|
-
} = options;
|
|
140
|
+
function validatePackageName(value, packages, options) {
|
|
141
|
+
const { isMonorepoSubProject } = options;
|
|
97
142
|
if (isMonorepoSubProject && packages.includes(value)) {
|
|
98
143
|
return {
|
|
99
144
|
success: false,
|
|
100
|
-
error: i18n.t(localeKeys.packageName.exit, {
|
|
101
|
-
value
|
|
102
|
-
})
|
|
145
|
+
error: i18n.t(localeKeys.packageName.exit, { value })
|
|
103
146
|
};
|
|
104
147
|
}
|
|
105
|
-
return {
|
|
106
|
-
success: true
|
|
107
|
-
};
|
|
148
|
+
return { success: true };
|
|
108
149
|
}
|
|
109
|
-
|
|
110
|
-
const {
|
|
111
|
-
|
|
112
|
-
isPublic,
|
|
113
|
-
isTest
|
|
114
|
-
} = options || {};
|
|
115
|
-
let dir = 'apps';
|
|
150
|
+
function validatePackagePath(value, projectDir, options) {
|
|
151
|
+
const { isMwa, isPublic, isTest } = options || {};
|
|
152
|
+
let dir = "apps";
|
|
116
153
|
if (isMwa && isTest) {
|
|
117
|
-
dir =
|
|
154
|
+
dir = "examples";
|
|
118
155
|
} else {
|
|
119
|
-
dir = isPublic ?
|
|
156
|
+
dir = isPublic ? "packages" : "features";
|
|
120
157
|
}
|
|
121
|
-
const packageDir = path.resolve(projectDir ||
|
|
158
|
+
const packageDir = path.resolve(projectDir || "", dir, value);
|
|
122
159
|
if (fs.existsSync(packageDir)) {
|
|
123
160
|
return {
|
|
124
161
|
success: false,
|
|
125
|
-
error: i18n.t(localeKeys.packagePath.exit, {
|
|
126
|
-
value
|
|
127
|
-
})
|
|
162
|
+
error: i18n.t(localeKeys.packagePath.exit, { value })
|
|
128
163
|
};
|
|
129
164
|
}
|
|
130
|
-
return {
|
|
131
|
-
success: true
|
|
132
|
-
};
|
|
165
|
+
return { success: true };
|
|
133
166
|
}
|
|
134
|
-
|
|
167
|
+
function getModuleProjectPath(packagePath, isMonorepoSubProject, isPublic, isLocalPackages) {
|
|
135
168
|
if (isLocalPackages && packagePath) {
|
|
136
169
|
return `${packagePath}/`;
|
|
137
170
|
}
|
|
138
171
|
if (isMonorepoSubProject && packagePath) {
|
|
139
|
-
return `${isPublic ?
|
|
172
|
+
return `${isPublic ? "packages" : "features"}/${packagePath}/`;
|
|
140
173
|
}
|
|
141
|
-
return
|
|
174
|
+
return "";
|
|
142
175
|
}
|
|
143
|
-
|
|
176
|
+
function getMWAProjectPath(packagePath, isMonorepoSubProject, isTest = false) {
|
|
144
177
|
if (isMonorepoSubProject && packagePath) {
|
|
145
|
-
return `${isTest ?
|
|
178
|
+
return `${isTest ? "examples" : "apps"}/${packagePath}/`;
|
|
146
179
|
}
|
|
147
|
-
return
|
|
148
|
-
}
|
|
180
|
+
return "";
|
|
181
|
+
}
|
|
182
|
+
export {
|
|
183
|
+
canUseNpm2 as canUseNpm,
|
|
184
|
+
canUsePnpm2 as canUsePnpm,
|
|
185
|
+
canUseYarn2 as canUseYarn,
|
|
186
|
+
execa2 as execa,
|
|
187
|
+
fs2 as fs,
|
|
188
|
+
getAllPackages,
|
|
189
|
+
getMWAProjectPath,
|
|
190
|
+
getModernPluginVersion,
|
|
191
|
+
getModernVersion,
|
|
192
|
+
getModuleProjectPath,
|
|
193
|
+
getPackageManager,
|
|
194
|
+
getPackageManagerText,
|
|
195
|
+
getPackageObj,
|
|
196
|
+
getPackageVersion,
|
|
197
|
+
i18n2 as i18n,
|
|
198
|
+
isReact18,
|
|
199
|
+
isTsProject,
|
|
200
|
+
ora2 as ora,
|
|
201
|
+
readTsConfigByFile,
|
|
202
|
+
semver,
|
|
203
|
+
validatePackageName,
|
|
204
|
+
validatePackagePath
|
|
205
|
+
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
packageName: {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
1
|
+
const EN_LOCALE = {
|
|
2
|
+
packageName: { exit: "package name `{value}` is already exists" },
|
|
3
|
+
packagePath: { exit: "package path {value} is already exists" }
|
|
4
|
+
};
|
|
5
|
+
export {
|
|
6
|
+
EN_LOCALE
|
|
7
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { I18n } from
|
|
1
|
+
import { I18n } from "@modern-js/plugin-i18n";
|
|
2
2
|
import { ZH_LOCALE } from "./zh";
|
|
3
3
|
import { EN_LOCALE } from "./en";
|
|
4
4
|
const i18n = new I18n();
|
|
5
|
-
const localeKeys = i18n.init(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
const localeKeys = i18n.init("zh", { zh: ZH_LOCALE, en: EN_LOCALE });
|
|
6
|
+
export {
|
|
7
|
+
i18n,
|
|
8
|
+
localeKeys
|
|
9
|
+
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
packageName: {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
1
|
+
const ZH_LOCALE = {
|
|
2
|
+
packageName: { exit: "项目名称 {value} 已存在" },
|
|
3
|
+
packagePath: { exit: "目录 {value} 已存在" }
|
|
4
|
+
};
|
|
5
|
+
export {
|
|
6
|
+
ZH_LOCALE
|
|
7
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from "./strip-ansi";
|
|
2
|
-
export * from "./package";
|
|
2
|
+
export * from "./package";
|
|
@@ -1,36 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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 { canUseNpm, execa, logger, semver, stripAnsi } from "@modern-js/utils";
|
|
22
|
+
function isPackageExist(packageName, registry) {
|
|
23
|
+
return __async(this, null, function* () {
|
|
24
|
+
if (yield canUseNpm()) {
|
|
25
|
+
const args = ["view", packageName, "version"];
|
|
26
|
+
if (registry) {
|
|
27
|
+
args.push(`--registry=${registry}`);
|
|
28
|
+
}
|
|
29
|
+
const result = yield execa("npm", args);
|
|
30
|
+
return stripAnsi(result.stdout);
|
|
9
31
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
throw new Error('not found npm, please install npm before');
|
|
32
|
+
throw new Error("not found npm, please install npm before");
|
|
33
|
+
});
|
|
14
34
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
35
|
+
function isPackageDeprecated(packageName, registry) {
|
|
36
|
+
return __async(this, null, function* () {
|
|
37
|
+
if (yield canUseNpm()) {
|
|
38
|
+
const args = ["view", packageName, "deprecated"];
|
|
39
|
+
if (registry) {
|
|
40
|
+
args.push(`--registry=${registry}`);
|
|
41
|
+
}
|
|
42
|
+
const result = yield execa("npm", args);
|
|
43
|
+
return stripAnsi(result.stdout);
|
|
22
44
|
}
|
|
23
|
-
|
|
24
|
-
return stripAnsi(result.stdout);
|
|
25
|
-
}
|
|
26
|
-
throw new Error('not found npm, please install npm before');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// 降低包小版本号
|
|
30
|
-
export function semverDecrease(version) {
|
|
31
|
-
const versionObj = semver.parse(version, {
|
|
32
|
-
loose: true
|
|
45
|
+
throw new Error("not found npm, please install npm before");
|
|
33
46
|
});
|
|
47
|
+
}
|
|
48
|
+
function semverDecrease(version) {
|
|
49
|
+
const versionObj = semver.parse(version, { loose: true });
|
|
34
50
|
if (!versionObj) {
|
|
35
51
|
throw new Error(`Version ${version} is not valid semver`);
|
|
36
52
|
}
|
|
@@ -44,31 +60,33 @@ export function semverDecrease(version) {
|
|
|
44
60
|
}
|
|
45
61
|
return result;
|
|
46
62
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
version = semver.inc(version, 'patch');
|
|
59
|
-
times--;
|
|
60
|
-
continue;
|
|
63
|
+
function getAvailableVersion(packageName, currentVersion, registry) {
|
|
64
|
+
return __async(this, null, function* () {
|
|
65
|
+
let times = 5;
|
|
66
|
+
let version = currentVersion;
|
|
67
|
+
while (times) {
|
|
68
|
+
if (!(yield isPackageExist(`${packageName}@${version}`, registry)) || (yield isPackageDeprecated(`${packageName}@${version}`, registry))) {
|
|
69
|
+
version = semver.inc(version, "patch");
|
|
70
|
+
times--;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
return version;
|
|
61
74
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
75
|
+
times = 5;
|
|
76
|
+
while (times) {
|
|
77
|
+
version = semverDecrease(version);
|
|
78
|
+
if (!(yield isPackageExist(`${packageName}@${version}`, registry)) || (yield isPackageDeprecated(`${packageName}@${version}`, registry))) {
|
|
79
|
+
times--;
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
return version;
|
|
70
83
|
}
|
|
71
|
-
return
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
84
|
+
return currentVersion;
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
export {
|
|
88
|
+
getAvailableVersion,
|
|
89
|
+
isPackageDeprecated,
|
|
90
|
+
isPackageExist,
|
|
91
|
+
semverDecrease
|
|
92
|
+
};
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
function ansiRegex({
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
function ansiRegex({ onlyFirst = false } = {}) {
|
|
2
|
+
const pattern = [
|
|
3
|
+
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
|
|
4
|
+
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"
|
|
5
|
+
].join("|");
|
|
6
|
+
return new RegExp(pattern, onlyFirst ? void 0 : "g");
|
|
6
7
|
}
|
|
7
|
-
|
|
8
|
-
if (typeof string !==
|
|
8
|
+
function stripAnsi(string) {
|
|
9
|
+
if (typeof string !== "string") {
|
|
9
10
|
throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
|
10
11
|
}
|
|
11
|
-
return string.replace(ansiRegex(),
|
|
12
|
-
}
|
|
12
|
+
return string.replace(ansiRegex(), "");
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
stripAnsi
|
|
16
|
+
};
|