upgrade-rspeedy 0.14.5 → 0.15.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 +2 -0
- package/dist/upgrade-rspeedy.js +496 -523
- package/package.json +9 -9
- package/dist/rslib-runtime.js +0 -138
package/CHANGELOG.md
CHANGED
package/dist/upgrade-rspeedy.js
CHANGED
|
@@ -1,13 +1,53 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
import node_process from "node:process";
|
|
3
|
+
import node_os, { EOL } from "node:os";
|
|
4
|
+
import node_tty from "node:tty";
|
|
5
|
+
import node_fs from "node:fs";
|
|
6
|
+
import node_path from "node:path";
|
|
7
|
+
import { createRequire } from "node:module";
|
|
8
|
+
import { createRequire as __rspack_createRequire } from "node:module";
|
|
9
|
+
const __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
|
|
10
|
+
var __webpack_modules__ = {};
|
|
11
|
+
var __webpack_module_cache__ = {};
|
|
12
|
+
function __webpack_require__(moduleId) {
|
|
13
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
14
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
15
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
16
|
+
exports: {}
|
|
17
|
+
};
|
|
18
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
19
|
+
return module.exports;
|
|
20
|
+
}
|
|
21
|
+
__webpack_require__.m = __webpack_modules__;
|
|
22
|
+
(()=>{
|
|
23
|
+
__webpack_require__.n = (module)=>{
|
|
24
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
25
|
+
__webpack_require__.d(getter, {
|
|
26
|
+
a: getter
|
|
27
|
+
});
|
|
28
|
+
return getter;
|
|
29
|
+
};
|
|
30
|
+
})();
|
|
31
|
+
(()=>{
|
|
32
|
+
__webpack_require__.d = (exports, getters, values)=>{
|
|
33
|
+
var define = (defs, kind)=>{
|
|
34
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
[kind]: defs[key]
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
define(getters, "get");
|
|
40
|
+
define(values, "value");
|
|
41
|
+
};
|
|
42
|
+
})();
|
|
43
|
+
(()=>{
|
|
44
|
+
__webpack_require__.add = function(modules) {
|
|
45
|
+
Object.assign(__webpack_require__.m, modules);
|
|
46
|
+
};
|
|
47
|
+
})();
|
|
48
|
+
(()=>{
|
|
49
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
50
|
+
})();
|
|
11
51
|
__webpack_require__.add({
|
|
12
52
|
"../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js" (module) {
|
|
13
53
|
let p = process || {}, argv = p.argv || [], env = p.env || {};
|
|
@@ -75,145 +115,20 @@ __webpack_require__.add({
|
|
|
75
115
|
module.exports = createColors();
|
|
76
116
|
module.exports.createColors = createColors;
|
|
77
117
|
},
|
|
78
|
-
"./src/install.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
79
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
80
|
-
a: ()=>install
|
|
81
|
-
});
|
|
82
|
-
var node_fs__rspack_import_0 = __webpack_require__("node:fs");
|
|
83
|
-
var node_os__rspack_import_1 = __webpack_require__("node:os");
|
|
84
|
-
var node_path__rspack_import_2 = __webpack_require__("node:path");
|
|
85
|
-
var detect_indent__rspack_import_6 = __webpack_require__("../../../node_modules/.pnpm/detect-indent@7.0.2/node_modules/detect-indent/index.js");
|
|
86
|
-
var picocolors__rspack_import_5 = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
87
|
-
var picocolors__rspack_import_5_default = /*#__PURE__*/ __webpack_require__.n(picocolors__rspack_import_5);
|
|
88
|
-
var rslog__rspack_import_3 = __webpack_require__("../../../node_modules/.pnpm/rslog@1.3.2/node_modules/rslog/dist/index.js");
|
|
89
|
-
var _version_js__rspack_import_4 = __webpack_require__("./src/version.ts");
|
|
90
|
-
const LYNX_RSPEEDY = '@lynx-js/rspeedy';
|
|
91
|
-
async function install(cwd) {
|
|
92
|
-
const packageJSONPath = node_path__rspack_import_2["default"].resolve(cwd, 'package.json');
|
|
93
|
-
if (!node_fs__rspack_import_0["default"].existsSync(packageJSONPath)) {
|
|
94
|
-
const message = `${picocolors__rspack_import_5_default().underline(picocolors__rspack_import_5_default().yellow(packageJSONPath))} not found. Please run ${picocolors__rspack_import_5_default().bold('upgrade-rspeedy')} in your Rspeedy project.`;
|
|
95
|
-
rslog__rspack_import_3.v.error(message);
|
|
96
|
-
throw new Error(message);
|
|
97
|
-
}
|
|
98
|
-
try {
|
|
99
|
-
const content = await node_fs__rspack_import_0["default"].promises.readFile(packageJSONPath, 'utf-8');
|
|
100
|
-
const pkg = JSON.parse(content);
|
|
101
|
-
if (pkg.dependencies?.[LYNX_RSPEEDY] === void 0 && pkg.devDependencies?.[LYNX_RSPEEDY] === void 0) throw new Error(`No ${picocolors__rspack_import_5_default().yellow(LYNX_RSPEEDY)} found in ${packageJSONPath}.
|
|
102
|
-
|
|
103
|
-
Please run ${picocolors__rspack_import_5_default().bold('upgrade-rspeedy')} in your Rspeedy project.`);
|
|
104
|
-
const { indent } = (0, detect_indent__rspack_import_6.A)(content);
|
|
105
|
-
console.info();
|
|
106
|
-
const dependenciesUpdated = updateDependencies(pkg, packageJSONPath, 'dependencies');
|
|
107
|
-
console.info();
|
|
108
|
-
const devDependenciesUpdated = updateDependencies(pkg, packageJSONPath, 'devDependencies');
|
|
109
|
-
console.info();
|
|
110
|
-
if (dependenciesUpdated || devDependenciesUpdated) {
|
|
111
|
-
await node_fs__rspack_import_0["default"].promises.writeFile(packageJSONPath, JSON.stringify(pkg, null, indent) + node_os__rspack_import_1.EOL, 'utf-8');
|
|
112
|
-
rslog__rspack_import_3.v.success(`${picocolors__rspack_import_5_default().yellow(packageJSONPath)} has been updated.`);
|
|
113
|
-
rslog__rspack_import_3.v.success("Please install the dependencies with your package manager.");
|
|
114
|
-
}
|
|
115
|
-
} catch (error) {
|
|
116
|
-
rslog__rspack_import_3.v.error(error);
|
|
117
|
-
throw error;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
function updateDependencies(pkg, packageJSONPath, name) {
|
|
121
|
-
const dependencies = pkg[name];
|
|
122
|
-
if (!dependencies) {
|
|
123
|
-
rslog__rspack_import_3.v.info(`No ${picocolors__rspack_import_5_default().yellow(name)} is found in ${picocolors__rspack_import_5_default().underline(packageJSONPath)}`);
|
|
124
|
-
return false;
|
|
125
|
-
}
|
|
126
|
-
const updatedDependencies = findDependencies(dependencies).filter(([, { original, target }])=>original !== target);
|
|
127
|
-
if (0 === updatedDependencies.length) {
|
|
128
|
-
rslog__rspack_import_3.v.info(`No ${picocolors__rspack_import_5_default().yellow(name)} need to be updated in ${picocolors__rspack_import_5_default().underline(packageJSONPath)}`);
|
|
129
|
-
return false;
|
|
130
|
-
}
|
|
131
|
-
{
|
|
132
|
-
const sep = '\n - ';
|
|
133
|
-
rslog__rspack_import_3.v.info(`Updated ${picocolors__rspack_import_5_default().yellow(name)}:\n${sep}${updatedDependencies.map(([name, { original, target }])=>`${picocolors__rspack_import_5_default().cyan(name)}: ${picocolors__rspack_import_5_default().dim(original)} -> ${picocolors__rspack_import_5_default().green(target)}`).join(sep)}`);
|
|
134
|
-
}
|
|
135
|
-
updatedDependencies.forEach(([dependency, { target }])=>{
|
|
136
|
-
dependencies[dependency] = target;
|
|
137
|
-
});
|
|
138
|
-
return true;
|
|
139
|
-
}
|
|
140
|
-
const targetDependencies = new Map(Object.entries(_version_js__rspack_import_4.r ?? {}));
|
|
141
|
-
function findDependencies(dependencies) {
|
|
142
|
-
return Object.entries(dependencies).map(([name, original])=>{
|
|
143
|
-
if (targetDependencies.has(name) && (name.startsWith('@lynx-js/') || name.includes('rsbuild'))) return [
|
|
144
|
-
name,
|
|
145
|
-
{
|
|
146
|
-
original,
|
|
147
|
-
target: targetDependencies.get(name)
|
|
148
|
-
}
|
|
149
|
-
];
|
|
150
|
-
return null;
|
|
151
|
-
}).filter((i)=>null !== i);
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
"./src/main.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
155
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
156
|
-
i: ()=>main
|
|
157
|
-
});
|
|
158
|
-
var commander__rspack_import_0 = __webpack_require__("../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/esm.mjs");
|
|
159
|
-
var rslog__rspack_import_1 = __webpack_require__("../../../node_modules/.pnpm/rslog@1.3.2/node_modules/rslog/dist/index.js");
|
|
160
|
-
var _install_js__rspack_import_2 = __webpack_require__("./src/install.ts");
|
|
161
|
-
var _version_js__rspack_import_3 = __webpack_require__("./src/version.ts");
|
|
162
|
-
async function main(cwd, argv) {
|
|
163
|
-
const program = new commander__rspack_import_0.uB('upgrade-rspeedy');
|
|
164
|
-
const { npm_execpath } = process.env;
|
|
165
|
-
if (!npm_execpath || npm_execpath.includes('npm-cli.js') || npm_execpath.includes('npx-cli.js')) console.info();
|
|
166
|
-
rslog__rspack_import_1.v.greet(`Upgrade Rspeedy v${_version_js__rspack_import_3.K}\n`);
|
|
167
|
-
program.helpCommand(false).description('Upgrade the Rspeedy-related packages').action(()=>(0, _install_js__rspack_import_2.a)(cwd ?? process.cwd()));
|
|
168
|
-
await program.parseAsync(argv);
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
"./src/upgrade-rspeedy.ts" (module, __webpack_exports__, __webpack_require__) {
|
|
172
|
-
__webpack_require__.a(module, async function(__rspack_load_async_deps, __rspack_async_done) {
|
|
173
|
-
try {
|
|
174
|
-
__webpack_require__.r(__webpack_exports__);
|
|
175
|
-
var _main_js__rspack_import_0 = __webpack_require__("./src/main.ts");
|
|
176
|
-
await (0, _main_js__rspack_import_0.i)();
|
|
177
|
-
__rspack_async_done();
|
|
178
|
-
} catch (e) {
|
|
179
|
-
__rspack_async_done(e);
|
|
180
|
-
}
|
|
181
|
-
}, 1);
|
|
182
|
-
},
|
|
183
|
-
"./src/version.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
184
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
185
|
-
K: ()=>version,
|
|
186
|
-
r: ()=>devDependencies
|
|
187
|
-
});
|
|
188
|
-
var node_module__rspack_import_0 = __webpack_require__("node:module");
|
|
189
|
-
const require = (0, node_module__rspack_import_0.createRequire)(import.meta.url);
|
|
190
|
-
const pkg = require('../package.json');
|
|
191
|
-
const version = pkg.version;
|
|
192
|
-
const devDependencies = pkg.devDependencies;
|
|
193
|
-
},
|
|
194
118
|
"node:child_process" (module) {
|
|
195
|
-
module.exports =
|
|
119
|
+
module.exports = __rspack_createRequire_require("node:child_process");
|
|
196
120
|
},
|
|
197
121
|
"node:events" (module) {
|
|
198
|
-
module.exports =
|
|
199
|
-
},
|
|
200
|
-
"node:fs" (module) {
|
|
201
|
-
module.exports = __rspack_external_node_fs_5ea92f0c;
|
|
202
|
-
},
|
|
203
|
-
"node:module" (module) {
|
|
204
|
-
module.exports = __rspack_external_node_module_ab9f2194;
|
|
205
|
-
},
|
|
206
|
-
"node:os" (module) {
|
|
207
|
-
module.exports = __rspack_external_node_os_74b4b876;
|
|
122
|
+
module.exports = __rspack_createRequire_require("node:events");
|
|
208
123
|
},
|
|
209
|
-
"node:
|
|
210
|
-
module.exports =
|
|
124
|
+
"node:fs?9592" (module) {
|
|
125
|
+
module.exports = __rspack_createRequire_require("node:fs");
|
|
211
126
|
},
|
|
212
|
-
"node:
|
|
213
|
-
module.exports =
|
|
127
|
+
"node:path?435f" (module) {
|
|
128
|
+
module.exports = __rspack_createRequire_require("node:path");
|
|
214
129
|
},
|
|
215
|
-
"node:
|
|
216
|
-
module.exports =
|
|
130
|
+
"node:process?ecf8" (module) {
|
|
131
|
+
module.exports = __rspack_createRequire_require("node:process");
|
|
217
132
|
},
|
|
218
133
|
"../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/index.js" (__unused_rspack_module, exports, __webpack_require__) {
|
|
219
134
|
const { Argument } = __webpack_require__("../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/lib/argument.js");
|
|
@@ -221,17 +136,17 @@ Please run ${picocolors__rspack_import_5_default().bold('upgrade-rspeedy')} in y
|
|
|
221
136
|
const { CommanderError, InvalidArgumentError } = __webpack_require__("../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/lib/error.js");
|
|
222
137
|
const { Help } = __webpack_require__("../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/lib/help.js");
|
|
223
138
|
const { Option } = __webpack_require__("../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/lib/option.js");
|
|
224
|
-
exports.
|
|
225
|
-
exports.
|
|
226
|
-
exports.
|
|
227
|
-
exports.
|
|
228
|
-
exports.
|
|
229
|
-
exports.
|
|
230
|
-
exports.
|
|
231
|
-
exports.
|
|
232
|
-
exports.
|
|
233
|
-
exports.
|
|
234
|
-
exports.
|
|
139
|
+
exports.DM = new Command();
|
|
140
|
+
exports.gu = (name)=>new Command(name);
|
|
141
|
+
exports.Ww = (flags, description)=>new Option(flags, description);
|
|
142
|
+
exports.er = (name, description)=>new Argument(name, description);
|
|
143
|
+
exports.uB = Command;
|
|
144
|
+
exports.c$ = Option;
|
|
145
|
+
exports.ef = Argument;
|
|
146
|
+
exports._V = Help;
|
|
147
|
+
exports.b7 = CommanderError;
|
|
148
|
+
exports.Di = InvalidArgumentError;
|
|
149
|
+
exports.a2 = InvalidArgumentError;
|
|
235
150
|
},
|
|
236
151
|
"../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/lib/argument.js" (__unused_rspack_module, exports, __webpack_require__) {
|
|
237
152
|
const { InvalidArgumentError } = __webpack_require__("../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/lib/error.js");
|
|
@@ -308,9 +223,9 @@ Please run ${picocolors__rspack_import_5_default().bold('upgrade-rspeedy')} in y
|
|
|
308
223
|
"../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/lib/command.js" (__unused_rspack_module, exports, __webpack_require__) {
|
|
309
224
|
const EventEmitter = __webpack_require__("node:events").EventEmitter;
|
|
310
225
|
const childProcess = __webpack_require__("node:child_process");
|
|
311
|
-
const path = __webpack_require__("node:path");
|
|
312
|
-
const fs = __webpack_require__("node:fs");
|
|
313
|
-
const process1 = __webpack_require__("node:process");
|
|
226
|
+
const path = __webpack_require__("node:path?435f");
|
|
227
|
+
const fs = __webpack_require__("node:fs?9592");
|
|
228
|
+
const process1 = __webpack_require__("node:process?ecf8");
|
|
314
229
|
const { Argument, humanReadableArgName } = __webpack_require__("../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/lib/argument.js");
|
|
315
230
|
const { CommanderError } = __webpack_require__("../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/lib/error.js");
|
|
316
231
|
const { Help, stripColor } = __webpack_require__("../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/lib/help.js");
|
|
@@ -1458,7 +1373,6 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1458
1373
|
if (process1.env.FORCE_COLOR || void 0 !== process1.env.CLICOLOR_FORCE) return true;
|
|
1459
1374
|
}
|
|
1460
1375
|
exports.Command = Command;
|
|
1461
|
-
exports.useColor = useColor;
|
|
1462
1376
|
},
|
|
1463
1377
|
"../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/lib/error.js" (__unused_rspack_module, exports) {
|
|
1464
1378
|
class CommanderError extends Error {
|
|
@@ -1952,378 +1866,437 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1952
1866
|
return '';
|
|
1953
1867
|
}
|
|
1954
1868
|
exports.suggestSimilar = suggestSimilar;
|
|
1955
|
-
}
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
}
|
|
2038
|
-
function makeIndentString(type, amount) {
|
|
2039
|
-
const indentCharacter = type === INDENT_TYPE_SPACE ? ' ' : '\t';
|
|
2040
|
-
return indentCharacter.repeat(amount);
|
|
1869
|
+
}
|
|
1870
|
+
});
|
|
1871
|
+
const commander = __webpack_require__("../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/index.js");
|
|
1872
|
+
const { DM: esm_program, gu: createCommand, er: createArgument, Ww: createOption, b7: CommanderError, Di: InvalidArgumentError, a2: InvalidOptionArgumentError, uB: Command, ef: Argument, c$: Option, _V: Help } = commander;
|
|
1873
|
+
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : node_process.argv) {
|
|
1874
|
+
const prefix = flag.startsWith('-') ? '' : 1 === flag.length ? '-' : '--';
|
|
1875
|
+
const position = argv.indexOf(prefix + flag);
|
|
1876
|
+
const terminatorPosition = argv.indexOf('--');
|
|
1877
|
+
return -1 !== position && (-1 === terminatorPosition || position < terminatorPosition);
|
|
1878
|
+
}
|
|
1879
|
+
const { env: env } = node_process;
|
|
1880
|
+
let flagForceColor;
|
|
1881
|
+
if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false') || hasFlag('color=never')) flagForceColor = 0;
|
|
1882
|
+
else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) flagForceColor = 1;
|
|
1883
|
+
function envForceColor() {
|
|
1884
|
+
if (!('FORCE_COLOR' in env)) return;
|
|
1885
|
+
if ('true' === env.FORCE_COLOR) return 1;
|
|
1886
|
+
if ('false' === env.FORCE_COLOR) return 0;
|
|
1887
|
+
if (0 === env.FORCE_COLOR.length) return 1;
|
|
1888
|
+
const level = Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
1889
|
+
if (![
|
|
1890
|
+
0,
|
|
1891
|
+
1,
|
|
1892
|
+
2,
|
|
1893
|
+
3
|
|
1894
|
+
].includes(level)) return;
|
|
1895
|
+
return level;
|
|
1896
|
+
}
|
|
1897
|
+
function translateLevel(level) {
|
|
1898
|
+
if (0 === level) return false;
|
|
1899
|
+
return {
|
|
1900
|
+
level,
|
|
1901
|
+
hasBasic: true,
|
|
1902
|
+
has256: level >= 2,
|
|
1903
|
+
has16m: level >= 3
|
|
1904
|
+
};
|
|
1905
|
+
}
|
|
1906
|
+
function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
1907
|
+
const noFlagForceColor = envForceColor();
|
|
1908
|
+
if (void 0 !== noFlagForceColor) flagForceColor = noFlagForceColor;
|
|
1909
|
+
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
1910
|
+
if (0 === forceColor) return 0;
|
|
1911
|
+
if (sniffFlags) {
|
|
1912
|
+
if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) return 3;
|
|
1913
|
+
if (hasFlag('color=256')) return 2;
|
|
1914
|
+
}
|
|
1915
|
+
if ('TF_BUILD' in env && 'AGENT_NAME' in env) return 1;
|
|
1916
|
+
if (haveStream && !streamIsTTY && void 0 === forceColor) return 0;
|
|
1917
|
+
const min = forceColor || 0;
|
|
1918
|
+
if ('dumb' === env.TERM) return min;
|
|
1919
|
+
if ('win32' === node_process.platform) {
|
|
1920
|
+
const osRelease = node_os.release().split('.');
|
|
1921
|
+
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
1922
|
+
return 1;
|
|
1923
|
+
}
|
|
1924
|
+
if ('CI' in env) {
|
|
1925
|
+
if ([
|
|
1926
|
+
'GITHUB_ACTIONS',
|
|
1927
|
+
'GITEA_ACTIONS',
|
|
1928
|
+
'CIRCLECI'
|
|
1929
|
+
].some((key)=>key in env)) return 3;
|
|
1930
|
+
if ([
|
|
1931
|
+
'TRAVIS',
|
|
1932
|
+
'APPVEYOR',
|
|
1933
|
+
'GITLAB_CI',
|
|
1934
|
+
'BUILDKITE',
|
|
1935
|
+
'DRONE'
|
|
1936
|
+
].some((sign)=>sign in env) || 'codeship' === env.CI_NAME) return 1;
|
|
1937
|
+
return min;
|
|
1938
|
+
}
|
|
1939
|
+
if ('TEAMCITY_VERSION' in env) return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
1940
|
+
if ('truecolor' === env.COLORTERM) return 3;
|
|
1941
|
+
if ('xterm-kitty' === env.TERM) return 3;
|
|
1942
|
+
if ('xterm-ghostty' === env.TERM) return 3;
|
|
1943
|
+
if ('wezterm' === env.TERM) return 3;
|
|
1944
|
+
if ('TERM_PROGRAM' in env) {
|
|
1945
|
+
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
|
1946
|
+
switch(env.TERM_PROGRAM){
|
|
1947
|
+
case 'iTerm.app':
|
|
1948
|
+
return version >= 3 ? 3 : 2;
|
|
1949
|
+
case 'Apple_Terminal':
|
|
1950
|
+
return 2;
|
|
2041
1951
|
}
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
1952
|
+
}
|
|
1953
|
+
if (/-256(color)?$/i.test(env.TERM)) return 2;
|
|
1954
|
+
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) return 1;
|
|
1955
|
+
if ('COLORTERM' in env) return 1;
|
|
1956
|
+
return min;
|
|
1957
|
+
}
|
|
1958
|
+
function createSupportsColor(stream, options = {}) {
|
|
1959
|
+
const level = _supportsColor(stream, {
|
|
1960
|
+
streamIsTTY: stream && stream.isTTY,
|
|
1961
|
+
...options
|
|
1962
|
+
});
|
|
1963
|
+
return translateLevel(level);
|
|
1964
|
+
}
|
|
1965
|
+
const supportsColor = {
|
|
1966
|
+
stdout: createSupportsColor({
|
|
1967
|
+
isTTY: node_tty.isatty(1)
|
|
1968
|
+
}),
|
|
1969
|
+
stderr: createSupportsColor({
|
|
1970
|
+
isTTY: node_tty.isatty(2)
|
|
1971
|
+
})
|
|
1972
|
+
};
|
|
1973
|
+
const supports_color = supportsColor;
|
|
1974
|
+
const colorLevel = supports_color.stdout ? supports_color.stdout.level : 0;
|
|
1975
|
+
let errorStackRegExp = /at [^\r\n]{0,200}:\d+:\d+[\s\)]*$/;
|
|
1976
|
+
let anonymousErrorStackRegExp = /at [^\r\n]{0,200}\(<anonymous>\)$/;
|
|
1977
|
+
let indexErrorStackRegExp = /at [^\r\n]{0,200}\(index\s\d+\)$/;
|
|
1978
|
+
let isErrorStackMessage = (message)=>errorStackRegExp.test(message) || anonymousErrorStackRegExp.test(message) || indexErrorStackRegExp.test(message);
|
|
1979
|
+
let formatter = (open, close, replace = open)=>colorLevel >= 2 ? (input)=>{
|
|
1980
|
+
let string = '' + input;
|
|
1981
|
+
let index = string.indexOf(close, open.length);
|
|
1982
|
+
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
1983
|
+
} : String;
|
|
1984
|
+
let replaceClose = (string, close, replace, index)=>{
|
|
1985
|
+
let start = string.substring(0, index) + replace;
|
|
1986
|
+
let end = string.substring(index + close.length);
|
|
1987
|
+
let nextIndex = end.indexOf(close);
|
|
1988
|
+
return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end;
|
|
1989
|
+
};
|
|
1990
|
+
const bold = formatter('\x1b[1m', '\x1b[22m', '\x1b[22m\x1b[1m');
|
|
1991
|
+
const red = formatter('\x1b[31m', '\x1b[39m');
|
|
1992
|
+
const green = formatter('\x1b[32m', '\x1b[39m');
|
|
1993
|
+
const yellow = formatter('\x1b[33m', '\x1b[39m');
|
|
1994
|
+
const magenta = formatter('\x1b[35m', '\x1b[39m');
|
|
1995
|
+
const cyan = formatter('\x1b[36m', '\x1b[39m');
|
|
1996
|
+
const gray = formatter('\x1b[90m', '\x1b[39m');
|
|
1997
|
+
let startColor = [
|
|
1998
|
+
189,
|
|
1999
|
+
255,
|
|
2000
|
+
243
|
|
2001
|
+
];
|
|
2002
|
+
let endColor = [
|
|
2003
|
+
74,
|
|
2004
|
+
194,
|
|
2005
|
+
154
|
|
2006
|
+
];
|
|
2007
|
+
let isWord = (char)=>!/[\s\n]/.test(char);
|
|
2008
|
+
let gradient = (message)=>{
|
|
2009
|
+
if (colorLevel < 3) return 2 === colorLevel ? bold(cyan(message)) : message;
|
|
2010
|
+
let chars = [
|
|
2011
|
+
...message
|
|
2012
|
+
];
|
|
2013
|
+
let steps = chars.filter(isWord).length;
|
|
2014
|
+
let r = startColor[0];
|
|
2015
|
+
let g = startColor[1];
|
|
2016
|
+
let b = startColor[2];
|
|
2017
|
+
let rStep = (endColor[0] - r) / steps;
|
|
2018
|
+
let gStep = (endColor[1] - g) / steps;
|
|
2019
|
+
let bStep = (endColor[2] - b) / steps;
|
|
2020
|
+
let output = '';
|
|
2021
|
+
for (let char of chars){
|
|
2022
|
+
if (isWord(char)) {
|
|
2023
|
+
r += rStep;
|
|
2024
|
+
g += gStep;
|
|
2025
|
+
b += bStep;
|
|
2059
2026
|
}
|
|
2027
|
+
output += `\x1b[38;2;${Math.round(r)};${Math.round(g)};${Math.round(b)}m${char}\x1b[39m`;
|
|
2028
|
+
}
|
|
2029
|
+
return bold(output);
|
|
2030
|
+
};
|
|
2031
|
+
let LOG_LEVEL = {
|
|
2032
|
+
silent: -1,
|
|
2033
|
+
error: 0,
|
|
2034
|
+
warn: 1,
|
|
2035
|
+
info: 2,
|
|
2036
|
+
log: 2,
|
|
2037
|
+
verbose: 3
|
|
2038
|
+
};
|
|
2039
|
+
let LOG_TYPES = {
|
|
2040
|
+
error: {
|
|
2041
|
+
label: 'error',
|
|
2042
|
+
level: 'error',
|
|
2043
|
+
color: red
|
|
2060
2044
|
},
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2045
|
+
warn: {
|
|
2046
|
+
label: 'warn',
|
|
2047
|
+
level: 'warn',
|
|
2048
|
+
color: yellow
|
|
2049
|
+
},
|
|
2050
|
+
info: {
|
|
2051
|
+
label: 'info',
|
|
2052
|
+
level: 'info',
|
|
2053
|
+
color: cyan
|
|
2054
|
+
},
|
|
2055
|
+
start: {
|
|
2056
|
+
label: 'start',
|
|
2057
|
+
level: 'info',
|
|
2058
|
+
color: cyan
|
|
2059
|
+
},
|
|
2060
|
+
ready: {
|
|
2061
|
+
label: 'ready',
|
|
2062
|
+
level: 'info',
|
|
2063
|
+
color: green
|
|
2064
|
+
},
|
|
2065
|
+
success: {
|
|
2066
|
+
label: 'success',
|
|
2067
|
+
level: 'info',
|
|
2068
|
+
color: green
|
|
2069
|
+
},
|
|
2070
|
+
log: {
|
|
2071
|
+
level: 'info'
|
|
2072
|
+
},
|
|
2073
|
+
debug: {
|
|
2074
|
+
label: 'debug',
|
|
2075
|
+
level: 'verbose',
|
|
2076
|
+
color: magenta
|
|
2077
|
+
}
|
|
2078
|
+
};
|
|
2079
|
+
const normalizeErrorMessage = (err)=>{
|
|
2080
|
+
if (err.stack) {
|
|
2081
|
+
let [name, ...rest] = err.stack.split('\n');
|
|
2082
|
+
if (name.startsWith('Error: ')) name = name.slice(7);
|
|
2083
|
+
return `${name}\n${gray(rest.join('\n'))}`;
|
|
2084
|
+
}
|
|
2085
|
+
return err.message;
|
|
2086
|
+
};
|
|
2087
|
+
let createLogger = (options = {})=>{
|
|
2088
|
+
let maxLevel = options.level || 'info';
|
|
2089
|
+
let log = (type, message, ...args)=>{
|
|
2090
|
+
let logType = LOG_TYPES[type];
|
|
2091
|
+
const { level } = logType;
|
|
2092
|
+
if (LOG_LEVEL[level] > LOG_LEVEL[maxLevel]) return;
|
|
2093
|
+
if (null == message) return console.log();
|
|
2094
|
+
let label = '';
|
|
2095
|
+
let text = '';
|
|
2096
|
+
if ('label' in logType) {
|
|
2097
|
+
label = (logType.label || '').padEnd(7);
|
|
2098
|
+
label = bold(logType.color ? logType.color(label) : label);
|
|
2099
|
+
}
|
|
2100
|
+
if (message instanceof Error) {
|
|
2101
|
+
text += normalizeErrorMessage(message);
|
|
2102
|
+
const { cause } = message;
|
|
2103
|
+
if (cause) {
|
|
2104
|
+
text += yellow('\n [cause]: ');
|
|
2105
|
+
text += cause instanceof Error ? normalizeErrorMessage(cause) : String(cause);
|
|
2106
|
+
}
|
|
2107
|
+
} else if ('error' === level && 'string' == typeof message) {
|
|
2108
|
+
let lines = message.split('\n');
|
|
2109
|
+
text = lines.map((line)=>isErrorStackMessage(line) ? gray(line) : line).join('\n');
|
|
2110
|
+
} else text = `${message}`;
|
|
2111
|
+
const method = 'error' === level || 'warn' === level ? level : 'log';
|
|
2112
|
+
console[method](label.length ? `${label} ${text}` : text, ...args);
|
|
2113
|
+
};
|
|
2114
|
+
let logger = {
|
|
2115
|
+
greet: (message)=>log('log', gradient(message))
|
|
2116
|
+
};
|
|
2117
|
+
Object.keys(LOG_TYPES).forEach((key)=>{
|
|
2118
|
+
logger[key] = (...args)=>log(key, ...args);
|
|
2119
|
+
});
|
|
2120
|
+
Object.defineProperty(logger, 'level', {
|
|
2121
|
+
get: ()=>maxLevel,
|
|
2122
|
+
set (val) {
|
|
2123
|
+
maxLevel = val;
|
|
2073
2124
|
}
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2125
|
+
});
|
|
2126
|
+
logger.override = (customLogger)=>{
|
|
2127
|
+
Object.assign(logger, customLogger);
|
|
2128
|
+
};
|
|
2129
|
+
return logger;
|
|
2130
|
+
};
|
|
2131
|
+
let src_logger = createLogger();
|
|
2132
|
+
const INDENT_REGEX = /^(?:( )+|\t+)/;
|
|
2133
|
+
const INDENT_TYPE_SPACE = 'space';
|
|
2134
|
+
const INDENT_TYPE_TAB = 'tab';
|
|
2135
|
+
function shouldIgnoreSingleSpace(ignoreSingleSpaces, indentType, value) {
|
|
2136
|
+
return ignoreSingleSpaces && indentType === INDENT_TYPE_SPACE && 1 === value;
|
|
2137
|
+
}
|
|
2138
|
+
function makeIndentsMap(string, ignoreSingleSpaces) {
|
|
2139
|
+
const indents = new Map();
|
|
2140
|
+
let previousSize = 0;
|
|
2141
|
+
let previousIndentType;
|
|
2142
|
+
let key;
|
|
2143
|
+
for (const line of string.split(/\n/g)){
|
|
2144
|
+
if (!line) continue;
|
|
2145
|
+
const matches = line.match(INDENT_REGEX);
|
|
2146
|
+
if (null === matches) {
|
|
2147
|
+
previousSize = 0;
|
|
2148
|
+
previousIndentType = '';
|
|
2149
|
+
} else {
|
|
2150
|
+
const indent = matches[0].length;
|
|
2151
|
+
const indentType = matches[1] ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;
|
|
2152
|
+
if (shouldIgnoreSingleSpace(ignoreSingleSpaces, indentType, indent)) continue;
|
|
2153
|
+
if (indentType !== previousIndentType) previousSize = 0;
|
|
2154
|
+
previousIndentType = indentType;
|
|
2155
|
+
let use = 1;
|
|
2156
|
+
let weight = 0;
|
|
2157
|
+
const indentDifference = indent - previousSize;
|
|
2158
|
+
previousSize = indent;
|
|
2159
|
+
if (0 === indentDifference) {
|
|
2160
|
+
use = 0;
|
|
2161
|
+
weight = 1;
|
|
2162
|
+
} else {
|
|
2163
|
+
const absoluteIndentDifference = Math.abs(indentDifference);
|
|
2164
|
+
if (shouldIgnoreSingleSpace(ignoreSingleSpaces, indentType, absoluteIndentDifference)) continue;
|
|
2165
|
+
key = encodeIndentsKey(indentType, absoluteIndentDifference);
|
|
2166
|
+
}
|
|
2167
|
+
const entry = indents.get(key);
|
|
2168
|
+
indents.set(key, void 0 === entry ? [
|
|
2086
2169
|
1,
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2170
|
+
0
|
|
2171
|
+
] : [
|
|
2172
|
+
entry[0] + use,
|
|
2173
|
+
entry[1] + weight
|
|
2174
|
+
]);
|
|
2091
2175
|
}
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2176
|
+
}
|
|
2177
|
+
return indents;
|
|
2178
|
+
}
|
|
2179
|
+
function encodeIndentsKey(indentType, indentAmount) {
|
|
2180
|
+
const typeCharacter = indentType === INDENT_TYPE_SPACE ? 's' : 't';
|
|
2181
|
+
return typeCharacter + String(indentAmount);
|
|
2182
|
+
}
|
|
2183
|
+
function decodeIndentsKey(indentsKey) {
|
|
2184
|
+
const keyHasTypeSpace = 's' === indentsKey[0];
|
|
2185
|
+
const type = keyHasTypeSpace ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;
|
|
2186
|
+
const amount = Number(indentsKey.slice(1));
|
|
2187
|
+
return {
|
|
2188
|
+
type,
|
|
2189
|
+
amount
|
|
2190
|
+
};
|
|
2191
|
+
}
|
|
2192
|
+
function getMostUsedKey(indents) {
|
|
2193
|
+
let result;
|
|
2194
|
+
let maxUsed = 0;
|
|
2195
|
+
let maxWeight = 0;
|
|
2196
|
+
for (const [key, [usedCount, weight]] of indents)if (usedCount > maxUsed || usedCount === maxUsed && weight > maxWeight) {
|
|
2197
|
+
maxUsed = usedCount;
|
|
2198
|
+
maxWeight = weight;
|
|
2199
|
+
result = key;
|
|
2200
|
+
}
|
|
2201
|
+
return result;
|
|
2202
|
+
}
|
|
2203
|
+
function makeIndentString(type, amount) {
|
|
2204
|
+
const indentCharacter = type === INDENT_TYPE_SPACE ? ' ' : '\t';
|
|
2205
|
+
return indentCharacter.repeat(amount);
|
|
2206
|
+
}
|
|
2207
|
+
function detectIndent(string) {
|
|
2208
|
+
if ('string' != typeof string) throw new TypeError('Expected a string');
|
|
2209
|
+
let indents = makeIndentsMap(string, true);
|
|
2210
|
+
if (0 === indents.size) indents = makeIndentsMap(string, false);
|
|
2211
|
+
const keyOfMostUsedIndent = getMostUsedKey(indents);
|
|
2212
|
+
let type;
|
|
2213
|
+
let amount = 0;
|
|
2214
|
+
let indent = '';
|
|
2215
|
+
if (void 0 !== keyOfMostUsedIndent) {
|
|
2216
|
+
({ type, amount } = decodeIndentsKey(keyOfMostUsedIndent));
|
|
2217
|
+
indent = makeIndentString(type, amount);
|
|
2218
|
+
}
|
|
2219
|
+
return {
|
|
2220
|
+
amount,
|
|
2221
|
+
type,
|
|
2222
|
+
indent
|
|
2223
|
+
};
|
|
2224
|
+
}
|
|
2225
|
+
const version_require = createRequire(import.meta.url);
|
|
2226
|
+
const version_pkg = version_require('../package.json');
|
|
2227
|
+
const version_version = version_pkg.version;
|
|
2228
|
+
const devDependencies = version_pkg.devDependencies;
|
|
2229
|
+
const picocolors = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
2230
|
+
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
2231
|
+
const LYNX_RSPEEDY = '@lynx-js/rspeedy';
|
|
2232
|
+
async function install(cwd) {
|
|
2233
|
+
const packageJSONPath = node_path.resolve(cwd, 'package.json');
|
|
2234
|
+
if (!node_fs.existsSync(packageJSONPath)) {
|
|
2235
|
+
const message = `${picocolors_default().underline(picocolors_default().yellow(packageJSONPath))} not found. Please run ${picocolors_default().bold('upgrade-rspeedy')} in your Rspeedy project.`;
|
|
2236
|
+
src_logger.error(message);
|
|
2237
|
+
throw new Error(message);
|
|
2238
|
+
}
|
|
2239
|
+
try {
|
|
2240
|
+
const content = await node_fs.promises.readFile(packageJSONPath, 'utf-8');
|
|
2241
|
+
const pkg = JSON.parse(content);
|
|
2242
|
+
if (pkg.dependencies?.[LYNX_RSPEEDY] === void 0 && pkg.devDependencies?.[LYNX_RSPEEDY] === void 0) throw new Error(`No ${picocolors_default().yellow(LYNX_RSPEEDY)} found in ${packageJSONPath}.
|
|
2243
|
+
|
|
2244
|
+
Please run ${picocolors_default().bold('upgrade-rspeedy')} in your Rspeedy project.`);
|
|
2245
|
+
const { indent } = detectIndent(content);
|
|
2246
|
+
console.info();
|
|
2247
|
+
const dependenciesUpdated = updateDependencies(pkg, packageJSONPath, 'dependencies');
|
|
2248
|
+
console.info();
|
|
2249
|
+
const devDependenciesUpdated = updateDependencies(pkg, packageJSONPath, 'devDependencies');
|
|
2250
|
+
console.info();
|
|
2251
|
+
if (dependenciesUpdated || devDependenciesUpdated) {
|
|
2252
|
+
await node_fs.promises.writeFile(packageJSONPath, JSON.stringify(pkg, null, indent) + EOL, 'utf-8');
|
|
2253
|
+
src_logger.success(`${picocolors_default().yellow(packageJSONPath)} has been updated.`);
|
|
2254
|
+
src_logger.success("Please install the dependencies with your package manager.");
|
|
2100
2255
|
}
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
if ('TEAMCITY_VERSION' in env) return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
2135
|
-
if ('truecolor' === env.COLORTERM) return 3;
|
|
2136
|
-
if ('xterm-kitty' === env.TERM) return 3;
|
|
2137
|
-
if ('xterm-ghostty' === env.TERM) return 3;
|
|
2138
|
-
if ('wezterm' === env.TERM) return 3;
|
|
2139
|
-
if ('TERM_PROGRAM' in env) {
|
|
2140
|
-
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
|
2141
|
-
switch(env.TERM_PROGRAM){
|
|
2142
|
-
case 'iTerm.app':
|
|
2143
|
-
return version >= 3 ? 3 : 2;
|
|
2144
|
-
case 'Apple_Terminal':
|
|
2145
|
-
return 2;
|
|
2146
|
-
}
|
|
2256
|
+
} catch (error) {
|
|
2257
|
+
src_logger.error(error);
|
|
2258
|
+
throw error;
|
|
2259
|
+
}
|
|
2260
|
+
}
|
|
2261
|
+
function updateDependencies(pkg, packageJSONPath, name) {
|
|
2262
|
+
const dependencies = pkg[name];
|
|
2263
|
+
if (!dependencies) {
|
|
2264
|
+
src_logger.info(`No ${picocolors_default().yellow(name)} is found in ${picocolors_default().underline(packageJSONPath)}`);
|
|
2265
|
+
return false;
|
|
2266
|
+
}
|
|
2267
|
+
const updatedDependencies = findDependencies(dependencies).filter(([, { original, target }])=>original !== target);
|
|
2268
|
+
if (0 === updatedDependencies.length) {
|
|
2269
|
+
src_logger.info(`No ${picocolors_default().yellow(name)} need to be updated in ${picocolors_default().underline(packageJSONPath)}`);
|
|
2270
|
+
return false;
|
|
2271
|
+
}
|
|
2272
|
+
{
|
|
2273
|
+
const sep = '\n - ';
|
|
2274
|
+
src_logger.info(`Updated ${picocolors_default().yellow(name)}:\n${sep}${updatedDependencies.map(([name, { original, target }])=>`${picocolors_default().cyan(name)}: ${picocolors_default().dim(original)} -> ${picocolors_default().green(target)}`).join(sep)}`);
|
|
2275
|
+
}
|
|
2276
|
+
updatedDependencies.forEach(([dependency, { target }])=>{
|
|
2277
|
+
dependencies[dependency] = target;
|
|
2278
|
+
});
|
|
2279
|
+
return true;
|
|
2280
|
+
}
|
|
2281
|
+
const targetDependencies = new Map(Object.entries(devDependencies ?? {}));
|
|
2282
|
+
function findDependencies(dependencies) {
|
|
2283
|
+
return Object.entries(dependencies).map(([name, original])=>{
|
|
2284
|
+
if (targetDependencies.has(name) && (name.startsWith('@lynx-js/') || name.includes('rsbuild'))) return [
|
|
2285
|
+
name,
|
|
2286
|
+
{
|
|
2287
|
+
original,
|
|
2288
|
+
target: targetDependencies.get(name)
|
|
2147
2289
|
}
|
|
2148
|
-
if (/-256(color)?$/i.test(env.TERM)) return 2;
|
|
2149
|
-
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) return 1;
|
|
2150
|
-
if ('COLORTERM' in env) return 1;
|
|
2151
|
-
return min;
|
|
2152
|
-
}
|
|
2153
|
-
function createSupportsColor(stream, options = {}) {
|
|
2154
|
-
const level = _supportsColor(stream, {
|
|
2155
|
-
streamIsTTY: stream && stream.isTTY,
|
|
2156
|
-
...options
|
|
2157
|
-
});
|
|
2158
|
-
return translateLevel(level);
|
|
2159
|
-
}
|
|
2160
|
-
const supportsColor = {
|
|
2161
|
-
stdout: createSupportsColor({
|
|
2162
|
-
isTTY: node_tty__rspack_import_2["default"].isatty(1)
|
|
2163
|
-
}),
|
|
2164
|
-
stderr: createSupportsColor({
|
|
2165
|
-
isTTY: node_tty__rspack_import_2["default"].isatty(2)
|
|
2166
|
-
})
|
|
2167
|
-
};
|
|
2168
|
-
const supports_color = supportsColor;
|
|
2169
|
-
const colorLevel = supports_color.stdout ? supports_color.stdout.level : 0;
|
|
2170
|
-
let errorStackRegExp = /at [^\r\n]{0,200}:\d+:\d+[\s\)]*$/;
|
|
2171
|
-
let anonymousErrorStackRegExp = /at [^\r\n]{0,200}\(<anonymous>\)$/;
|
|
2172
|
-
let indexErrorStackRegExp = /at [^\r\n]{0,200}\(index\s\d+\)$/;
|
|
2173
|
-
let isErrorStackMessage = (message)=>errorStackRegExp.test(message) || anonymousErrorStackRegExp.test(message) || indexErrorStackRegExp.test(message);
|
|
2174
|
-
let formatter = (open, close, replace = open)=>colorLevel >= 2 ? (input)=>{
|
|
2175
|
-
let string = '' + input;
|
|
2176
|
-
let index = string.indexOf(close, open.length);
|
|
2177
|
-
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
2178
|
-
} : String;
|
|
2179
|
-
let replaceClose = (string, close, replace, index)=>{
|
|
2180
|
-
let start = string.substring(0, index) + replace;
|
|
2181
|
-
let end = string.substring(index + close.length);
|
|
2182
|
-
let nextIndex = end.indexOf(close);
|
|
2183
|
-
return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end;
|
|
2184
|
-
};
|
|
2185
|
-
const bold = formatter('\x1b[1m', '\x1b[22m', '\x1b[22m\x1b[1m');
|
|
2186
|
-
const red = formatter('\x1b[31m', '\x1b[39m');
|
|
2187
|
-
const green = formatter('\x1b[32m', '\x1b[39m');
|
|
2188
|
-
const yellow = formatter('\x1b[33m', '\x1b[39m');
|
|
2189
|
-
const magenta = formatter('\x1b[35m', '\x1b[39m');
|
|
2190
|
-
const cyan = formatter('\x1b[36m', '\x1b[39m');
|
|
2191
|
-
const gray = formatter('\x1b[90m', '\x1b[39m');
|
|
2192
|
-
let startColor = [
|
|
2193
|
-
189,
|
|
2194
|
-
255,
|
|
2195
|
-
243
|
|
2196
|
-
];
|
|
2197
|
-
let endColor = [
|
|
2198
|
-
74,
|
|
2199
|
-
194,
|
|
2200
|
-
154
|
|
2201
2290
|
];
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
let bStep = (endColor[2] - b) / steps;
|
|
2215
|
-
let output = '';
|
|
2216
|
-
for (let char of chars){
|
|
2217
|
-
if (isWord(char)) {
|
|
2218
|
-
r += rStep;
|
|
2219
|
-
g += gStep;
|
|
2220
|
-
b += bStep;
|
|
2221
|
-
}
|
|
2222
|
-
output += `\x1b[38;2;${Math.round(r)};${Math.round(g)};${Math.round(b)}m${char}\x1b[39m`;
|
|
2223
|
-
}
|
|
2224
|
-
return bold(output);
|
|
2225
|
-
};
|
|
2226
|
-
let LOG_LEVEL = {
|
|
2227
|
-
silent: -1,
|
|
2228
|
-
error: 0,
|
|
2229
|
-
warn: 1,
|
|
2230
|
-
info: 2,
|
|
2231
|
-
log: 2,
|
|
2232
|
-
verbose: 3
|
|
2233
|
-
};
|
|
2234
|
-
let LOG_TYPES = {
|
|
2235
|
-
error: {
|
|
2236
|
-
label: 'error',
|
|
2237
|
-
level: 'error',
|
|
2238
|
-
color: red
|
|
2239
|
-
},
|
|
2240
|
-
warn: {
|
|
2241
|
-
label: 'warn',
|
|
2242
|
-
level: 'warn',
|
|
2243
|
-
color: yellow
|
|
2244
|
-
},
|
|
2245
|
-
info: {
|
|
2246
|
-
label: 'info',
|
|
2247
|
-
level: 'info',
|
|
2248
|
-
color: cyan
|
|
2249
|
-
},
|
|
2250
|
-
start: {
|
|
2251
|
-
label: 'start',
|
|
2252
|
-
level: 'info',
|
|
2253
|
-
color: cyan
|
|
2254
|
-
},
|
|
2255
|
-
ready: {
|
|
2256
|
-
label: 'ready',
|
|
2257
|
-
level: 'info',
|
|
2258
|
-
color: green
|
|
2259
|
-
},
|
|
2260
|
-
success: {
|
|
2261
|
-
label: 'success',
|
|
2262
|
-
level: 'info',
|
|
2263
|
-
color: green
|
|
2264
|
-
},
|
|
2265
|
-
log: {
|
|
2266
|
-
level: 'info'
|
|
2267
|
-
},
|
|
2268
|
-
debug: {
|
|
2269
|
-
label: 'debug',
|
|
2270
|
-
level: 'verbose',
|
|
2271
|
-
color: magenta
|
|
2272
|
-
}
|
|
2273
|
-
};
|
|
2274
|
-
const normalizeErrorMessage = (err)=>{
|
|
2275
|
-
if (err.stack) {
|
|
2276
|
-
let [name, ...rest] = err.stack.split('\n');
|
|
2277
|
-
if (name.startsWith('Error: ')) name = name.slice(7);
|
|
2278
|
-
return `${name}\n${gray(rest.join('\n'))}`;
|
|
2279
|
-
}
|
|
2280
|
-
return err.message;
|
|
2281
|
-
};
|
|
2282
|
-
let createLogger = (options = {})=>{
|
|
2283
|
-
let maxLevel = options.level || 'info';
|
|
2284
|
-
let log = (type, message, ...args)=>{
|
|
2285
|
-
let logType = LOG_TYPES[type];
|
|
2286
|
-
const { level } = logType;
|
|
2287
|
-
if (LOG_LEVEL[level] > LOG_LEVEL[maxLevel]) return;
|
|
2288
|
-
if (null == message) return console.log();
|
|
2289
|
-
let label = '';
|
|
2290
|
-
let text = '';
|
|
2291
|
-
if ('label' in logType) {
|
|
2292
|
-
label = (logType.label || '').padEnd(7);
|
|
2293
|
-
label = bold(logType.color ? logType.color(label) : label);
|
|
2294
|
-
}
|
|
2295
|
-
if (message instanceof Error) {
|
|
2296
|
-
text += normalizeErrorMessage(message);
|
|
2297
|
-
const { cause } = message;
|
|
2298
|
-
if (cause) {
|
|
2299
|
-
text += yellow('\n [cause]: ');
|
|
2300
|
-
text += cause instanceof Error ? normalizeErrorMessage(cause) : String(cause);
|
|
2301
|
-
}
|
|
2302
|
-
} else if ('error' === level && 'string' == typeof message) {
|
|
2303
|
-
let lines = message.split('\n');
|
|
2304
|
-
text = lines.map((line)=>isErrorStackMessage(line) ? gray(line) : line).join('\n');
|
|
2305
|
-
} else text = `${message}`;
|
|
2306
|
-
const method = 'error' === level || 'warn' === level ? level : 'log';
|
|
2307
|
-
console[method](label.length ? `${label} ${text}` : text, ...args);
|
|
2308
|
-
};
|
|
2309
|
-
let logger = {
|
|
2310
|
-
greet: (message)=>log('log', gradient(message))
|
|
2311
|
-
};
|
|
2312
|
-
Object.keys(LOG_TYPES).forEach((key)=>{
|
|
2313
|
-
logger[key] = (...args)=>log(key, ...args);
|
|
2314
|
-
});
|
|
2315
|
-
Object.defineProperty(logger, 'level', {
|
|
2316
|
-
get: ()=>maxLevel,
|
|
2317
|
-
set (val) {
|
|
2318
|
-
maxLevel = val;
|
|
2319
|
-
}
|
|
2320
|
-
});
|
|
2321
|
-
logger.override = (customLogger)=>{
|
|
2322
|
-
Object.assign(logger, customLogger);
|
|
2323
|
-
};
|
|
2324
|
-
return logger;
|
|
2325
|
-
};
|
|
2326
|
-
let src_logger = createLogger();
|
|
2327
|
-
}
|
|
2328
|
-
});
|
|
2329
|
-
__webpack_require__("./src/upgrade-rspeedy.ts");
|
|
2291
|
+
return null;
|
|
2292
|
+
}).filter((i)=>null !== i);
|
|
2293
|
+
}
|
|
2294
|
+
async function main(cwd, argv) {
|
|
2295
|
+
const program = new Command('upgrade-rspeedy');
|
|
2296
|
+
const { npm_execpath } = process.env;
|
|
2297
|
+
if (!npm_execpath || npm_execpath.includes('npm-cli.js') || npm_execpath.includes('npx-cli.js')) console.info();
|
|
2298
|
+
src_logger.greet(`Upgrade Rspeedy v${version_version}\n`);
|
|
2299
|
+
program.helpCommand(false).description('Upgrade the Rspeedy-related packages').action(()=>install(cwd ?? process.cwd()));
|
|
2300
|
+
await program.parseAsync(argv);
|
|
2301
|
+
}
|
|
2302
|
+
await main();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "upgrade-rspeedy",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Upgrade Rspeedy-related packages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"webpack",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
],
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@lynx-js/types": "3.7.0",
|
|
34
|
-
"@rsbuild/plugin-less": "1.6.
|
|
35
|
-
"@rsbuild/plugin-sass": "1.5.
|
|
34
|
+
"@rsbuild/plugin-less": "1.6.3",
|
|
35
|
+
"@rsbuild/plugin-sass": "1.5.2",
|
|
36
36
|
"commander": "^13.1.0",
|
|
37
37
|
"detect-indent": "^7.0.2",
|
|
38
38
|
"memfs": "^4.56.10",
|
|
@@ -40,12 +40,12 @@
|
|
|
40
40
|
"rsbuild-plugin-tailwindcss": "0.2.4",
|
|
41
41
|
"rslog": "^1.3.2",
|
|
42
42
|
"type-fest": "^5.4.4",
|
|
43
|
-
"@lynx-js/qrcode-rsbuild-plugin": "0.
|
|
44
|
-
"@lynx-js/react": "0.121.
|
|
45
|
-
"@lynx-js/react-rsbuild-plugin": "0.
|
|
46
|
-
"@lynx-js/rspeedy": "0.
|
|
47
|
-
"@lynx-js/web-core": "0.21.
|
|
48
|
-
"@lynx-js/web-elements": "0.12.
|
|
43
|
+
"@lynx-js/qrcode-rsbuild-plugin": "0.5.0",
|
|
44
|
+
"@lynx-js/react": "0.121.2",
|
|
45
|
+
"@lynx-js/react-rsbuild-plugin": "0.17.0",
|
|
46
|
+
"@lynx-js/rspeedy": "0.15.0",
|
|
47
|
+
"@lynx-js/web-core": "0.21.1",
|
|
48
|
+
"@lynx-js/web-elements": "0.12.4"
|
|
49
49
|
},
|
|
50
50
|
"engines": {
|
|
51
51
|
"node": ">=18"
|
package/dist/rslib-runtime.js
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
var __webpack_modules__ = {};
|
|
2
|
-
var __webpack_module_cache__ = {};
|
|
3
|
-
function __webpack_require__(moduleId) {
|
|
4
|
-
var cachedModule = __webpack_module_cache__[moduleId];
|
|
5
|
-
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
6
|
-
var module = __webpack_module_cache__[moduleId] = {
|
|
7
|
-
exports: {}
|
|
8
|
-
};
|
|
9
|
-
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
10
|
-
return module.exports;
|
|
11
|
-
}
|
|
12
|
-
__webpack_require__.m = __webpack_modules__;
|
|
13
|
-
(()=>{
|
|
14
|
-
__webpack_require__.add = function(modules) {
|
|
15
|
-
Object.assign(__webpack_require__.m, modules);
|
|
16
|
-
};
|
|
17
|
-
})();
|
|
18
|
-
(()=>{
|
|
19
|
-
var hasSymbol = "function" == typeof Symbol;
|
|
20
|
-
var rspackQueues = hasSymbol ? Symbol("rspack queues") : "__rspack_queues";
|
|
21
|
-
var rspackExports = __webpack_require__.aE = hasSymbol ? Symbol("rspack exports") : "__webpack_exports__";
|
|
22
|
-
var rspackError = hasSymbol ? Symbol("rspack error") : "__rspack_error";
|
|
23
|
-
var rspackDone = hasSymbol ? Symbol("rspack done") : "__rspack_done";
|
|
24
|
-
var rspackDefer = __webpack_require__.zS = hasSymbol ? Symbol("rspack defer") : "__rspack_defer";
|
|
25
|
-
var resolveQueue = (queue)=>{
|
|
26
|
-
if (queue && queue.d < 1) {
|
|
27
|
-
queue.d = 1;
|
|
28
|
-
queue.forEach((fn)=>fn.r--);
|
|
29
|
-
queue.forEach((fn)=>fn.r-- ? fn.r++ : fn());
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
var wrapDeps = (deps)=>deps.map((dep)=>{
|
|
33
|
-
if (null !== dep && "object" == typeof dep) {
|
|
34
|
-
if (!dep[rspackQueues] && dep[rspackDefer]) {
|
|
35
|
-
var asyncDeps = dep[rspackDefer];
|
|
36
|
-
var hasUnresolvedAsyncSubgraph = asyncDeps.some((id)=>{
|
|
37
|
-
var cache = __webpack_module_cache__[id];
|
|
38
|
-
return !cache || false === cache[rspackDone];
|
|
39
|
-
});
|
|
40
|
-
if (!hasUnresolvedAsyncSubgraph) return dep;
|
|
41
|
-
var d = dep;
|
|
42
|
-
dep = {
|
|
43
|
-
then (callback) {
|
|
44
|
-
Promise.all(asyncDeps.map(__webpack_require__)).then(()=>callback(d));
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
if (dep[rspackQueues]) return dep;
|
|
49
|
-
if (dep.then) {
|
|
50
|
-
var queue = [];
|
|
51
|
-
queue.d = 0;
|
|
52
|
-
dep.then((r)=>{
|
|
53
|
-
obj[rspackExports] = r;
|
|
54
|
-
resolveQueue(queue);
|
|
55
|
-
}, (e)=>{
|
|
56
|
-
obj[rspackError] = e;
|
|
57
|
-
resolveQueue(queue);
|
|
58
|
-
});
|
|
59
|
-
var obj = {};
|
|
60
|
-
obj[rspackDefer] = false;
|
|
61
|
-
obj[rspackQueues] = (fn)=>fn(queue);
|
|
62
|
-
return obj;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
var ret = {};
|
|
66
|
-
ret[rspackQueues] = ()=>{};
|
|
67
|
-
ret[rspackExports] = dep;
|
|
68
|
-
return ret;
|
|
69
|
-
});
|
|
70
|
-
__webpack_require__.a = (module, body, hasAwait)=>{
|
|
71
|
-
var queue;
|
|
72
|
-
hasAwait && ((queue = []).d = -1);
|
|
73
|
-
var depQueues = new Set();
|
|
74
|
-
var exports = module.exports;
|
|
75
|
-
var currentDeps;
|
|
76
|
-
var outerResolve;
|
|
77
|
-
var reject;
|
|
78
|
-
var promise = new Promise((resolve, rej)=>{
|
|
79
|
-
reject = rej;
|
|
80
|
-
outerResolve = resolve;
|
|
81
|
-
});
|
|
82
|
-
promise[rspackExports] = exports;
|
|
83
|
-
promise[rspackQueues] = (fn)=>{
|
|
84
|
-
queue && fn(queue), depQueues.forEach(fn), promise["catch"](()=>{});
|
|
85
|
-
};
|
|
86
|
-
module.exports = promise;
|
|
87
|
-
var handle = (deps)=>{
|
|
88
|
-
currentDeps = wrapDeps(deps);
|
|
89
|
-
var fn;
|
|
90
|
-
var getResult = ()=>currentDeps.map((d)=>{
|
|
91
|
-
if (d[rspackDefer]) return d;
|
|
92
|
-
if (d[rspackError]) throw d[rspackError];
|
|
93
|
-
return d[rspackExports];
|
|
94
|
-
});
|
|
95
|
-
var promise = new Promise((resolve)=>{
|
|
96
|
-
fn = ()=>resolve(getResult);
|
|
97
|
-
fn.r = 0;
|
|
98
|
-
var fnQueue = (q)=>q !== queue && !depQueues.has(q) && (depQueues.add(q), q && !q.d && (fn.r++, q.push(fn)));
|
|
99
|
-
currentDeps.map((dep)=>dep[rspackDefer] || dep[rspackQueues](fnQueue));
|
|
100
|
-
});
|
|
101
|
-
return fn.r ? promise : getResult();
|
|
102
|
-
};
|
|
103
|
-
var done = (err)=>(err ? reject(promise[rspackError] = err) : outerResolve(exports), resolveQueue(queue), promise[rspackDone] = true);
|
|
104
|
-
body(handle, done);
|
|
105
|
-
queue && queue.d < 0 && (queue.d = 0);
|
|
106
|
-
};
|
|
107
|
-
})();
|
|
108
|
-
(()=>{
|
|
109
|
-
__webpack_require__.n = (module)=>{
|
|
110
|
-
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
111
|
-
__webpack_require__.d(getter, {
|
|
112
|
-
a: getter
|
|
113
|
-
});
|
|
114
|
-
return getter;
|
|
115
|
-
};
|
|
116
|
-
})();
|
|
117
|
-
(()=>{
|
|
118
|
-
__webpack_require__.d = (exports, definition)=>{
|
|
119
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
|
|
120
|
-
enumerable: true,
|
|
121
|
-
get: definition[key]
|
|
122
|
-
});
|
|
123
|
-
};
|
|
124
|
-
})();
|
|
125
|
-
(()=>{
|
|
126
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
127
|
-
})();
|
|
128
|
-
(()=>{
|
|
129
|
-
__webpack_require__.r = (exports)=>{
|
|
130
|
-
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports, Symbol.toStringTag, {
|
|
131
|
-
value: 'Module'
|
|
132
|
-
});
|
|
133
|
-
Object.defineProperty(exports, '__esModule', {
|
|
134
|
-
value: true
|
|
135
|
-
});
|
|
136
|
-
};
|
|
137
|
-
})();
|
|
138
|
-
export { __webpack_require__ };
|