@icebreakers/monorepo 0.6.5 → 0.6.6
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/{chunk-E44XFEVA.js → chunk-43YMCN4J.js} +399 -79
- package/dist/cli.cjs +14 -7
- package/dist/cli.js +5 -314
- package/dist/index.cjs +353 -18
- package/dist/index.d.cts +48 -1
- package/dist/index.d.ts +48 -1
- package/dist/index.js +21 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
__toESM,
|
|
2
|
+
cleanProjects,
|
|
4
3
|
createNewProject,
|
|
4
|
+
init,
|
|
5
5
|
init_esm_shims,
|
|
6
6
|
logger,
|
|
7
7
|
name,
|
|
8
|
-
|
|
8
|
+
setVscodeBinaryMirror,
|
|
9
|
+
syncNpmMirror,
|
|
9
10
|
upgradeMonorepo,
|
|
10
11
|
version
|
|
11
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-43YMCN4J.js";
|
|
12
13
|
|
|
13
14
|
// src/cli.ts
|
|
14
15
|
init_esm_shims();
|
|
@@ -17,316 +18,6 @@ init_esm_shims();
|
|
|
17
18
|
init_esm_shims();
|
|
18
19
|
import process from "node:process";
|
|
19
20
|
import { program } from "commander";
|
|
20
|
-
|
|
21
|
-
// src/monorepo/index.ts
|
|
22
|
-
init_esm_shims();
|
|
23
|
-
|
|
24
|
-
// src/monorepo/binaryMirror.ts
|
|
25
|
-
init_esm_shims();
|
|
26
|
-
import { parse, stringify } from "comment-json";
|
|
27
|
-
import fs from "fs-extra";
|
|
28
|
-
import path from "pathe";
|
|
29
|
-
|
|
30
|
-
// src/monorepo/mirror/sources.ts
|
|
31
|
-
init_esm_shims();
|
|
32
|
-
var chinaMirrorsEnvs = {
|
|
33
|
-
COREPACK_NPM_REGISTRY: "https://registry.npmmirror.com",
|
|
34
|
-
EDGEDRIVER_CDNURL: "https://npmmirror.com/mirrors/edgedriver",
|
|
35
|
-
NODEJS_ORG_MIRROR: "https://cdn.npmmirror.com/binaries/node",
|
|
36
|
-
NVM_NODEJS_ORG_MIRROR: "https://cdn.npmmirror.com/binaries/node",
|
|
37
|
-
PHANTOMJS_CDNURL: "https://cdn.npmmirror.com/binaries/phantomjs",
|
|
38
|
-
CHROMEDRIVER_CDNURL: "https://cdn.npmmirror.com/binaries/chromedriver",
|
|
39
|
-
OPERADRIVER_CDNURL: "https://cdn.npmmirror.com/binaries/operadriver",
|
|
40
|
-
CYPRESS_DOWNLOAD_PATH_TEMPLATE: "https://cdn.npmmirror.com/binaries/cypress/${version}/${platform}-${arch}/cypress.zip",
|
|
41
|
-
ELECTRON_MIRROR: "https://cdn.npmmirror.com/binaries/electron/",
|
|
42
|
-
ELECTRON_BUILDER_BINARIES_MIRROR: "https://cdn.npmmirror.com/binaries/electron-builder-binaries/",
|
|
43
|
-
SASS_BINARY_SITE: "https://cdn.npmmirror.com/binaries/node-sass",
|
|
44
|
-
SWC_BINARY_SITE: "https://cdn.npmmirror.com/binaries/node-swc",
|
|
45
|
-
NWJS_URLBASE: "https://cdn.npmmirror.com/binaries/nwjs/v",
|
|
46
|
-
PUPPETEER_DOWNLOAD_HOST: "https://cdn.npmmirror.com/binaries/chrome-for-testing",
|
|
47
|
-
PUPPETEER_DOWNLOAD_BASE_URL: "https://cdn.npmmirror.com/binaries/chrome-for-testing",
|
|
48
|
-
PLAYWRIGHT_DOWNLOAD_HOST: "https://cdn.npmmirror.com/binaries/playwright",
|
|
49
|
-
SENTRYCLI_CDNURL: "https://cdn.npmmirror.com/binaries/sentry-cli",
|
|
50
|
-
SAUCECTL_INSTALL_BINARY_MIRROR: "https://cdn.npmmirror.com/binaries/saucectl",
|
|
51
|
-
RE2_DOWNLOAD_MIRROR: "https://cdn.npmmirror.com/binaries/node-re2",
|
|
52
|
-
RE2_DOWNLOAD_SKIP_PATH: "true",
|
|
53
|
-
PRISMA_ENGINES_MIRROR: "https://cdn.npmmirror.com/binaries/prisma",
|
|
54
|
-
npm_config_better_sqlite3_binary_host: "https://cdn.npmmirror.com/binaries/better-sqlite3",
|
|
55
|
-
npm_config_keytar_binary_host: "https://cdn.npmmirror.com/binaries/keytar",
|
|
56
|
-
npm_config_sharp_binary_host: "https://cdn.npmmirror.com/binaries/sharp",
|
|
57
|
-
npm_config_sharp_libvips_binary_host: "https://cdn.npmmirror.com/binaries/sharp-libvips",
|
|
58
|
-
npm_config_robotjs_binary_host: "https://cdn.npmmirror.com/binaries/robotjs"
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
// src/monorepo/mirror/utils.ts
|
|
62
|
-
init_esm_shims();
|
|
63
|
-
var import_set_value = __toESM(require_set_value(), 1);
|
|
64
|
-
function setMirror(obj) {
|
|
65
|
-
const platforms = ["linux", "windows", "osx"];
|
|
66
|
-
const prefix = "terminal.integrated.env";
|
|
67
|
-
if (typeof obj === "object" && obj) {
|
|
68
|
-
for (const platform of platforms) {
|
|
69
|
-
(0, import_set_value.default)(obj, [prefix, platform].join(".").replaceAll(".", "\\."), chinaMirrorsEnvs);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// src/monorepo/binaryMirror.ts
|
|
75
|
-
async function setVscodeBinaryMirror(cwd2) {
|
|
76
|
-
const targetJsonPath = path.resolve(cwd2, ".vscode/settings.json");
|
|
77
|
-
await fs.ensureFile(targetJsonPath);
|
|
78
|
-
const json = parse(await fs.readFile(targetJsonPath, "utf8"), void 0, false);
|
|
79
|
-
json && typeof json === "object" && setMirror(json);
|
|
80
|
-
await fs.writeFile(targetJsonPath, `${stringify(json, void 0, 2)}
|
|
81
|
-
`, "utf8");
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// src/monorepo/clean.ts
|
|
85
|
-
init_esm_shims();
|
|
86
|
-
import fs2 from "fs-extra";
|
|
87
|
-
import path2 from "pathe";
|
|
88
|
-
var dirs = [
|
|
89
|
-
"packages/monorepo",
|
|
90
|
-
"packages/foo",
|
|
91
|
-
// 'apps/cli',
|
|
92
|
-
// 'apps/website',
|
|
93
|
-
"apps"
|
|
94
|
-
];
|
|
95
|
-
async function cleanProjects(cwd2) {
|
|
96
|
-
for (const dir of dirs.map((x) => {
|
|
97
|
-
return path2.resolve(cwd2, x);
|
|
98
|
-
})) {
|
|
99
|
-
await fs2.remove(dir);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// src/monorepo/init.ts
|
|
104
|
-
init_esm_shims();
|
|
105
|
-
|
|
106
|
-
// src/monorepo/context.ts
|
|
107
|
-
init_esm_shims();
|
|
108
|
-
import path4 from "pathe";
|
|
109
|
-
|
|
110
|
-
// src/monorepo/workspace.ts
|
|
111
|
-
init_esm_shims();
|
|
112
|
-
import { findWorkspacePackages } from "@pnpm/workspace.find-packages";
|
|
113
|
-
|
|
114
|
-
// ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
|
|
115
|
-
init_esm_shims();
|
|
116
|
-
function isPlainObject(value) {
|
|
117
|
-
if (value === null || typeof value !== "object") {
|
|
118
|
-
return false;
|
|
119
|
-
}
|
|
120
|
-
const prototype = Object.getPrototypeOf(value);
|
|
121
|
-
if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
|
|
122
|
-
return false;
|
|
123
|
-
}
|
|
124
|
-
if (Symbol.iterator in value) {
|
|
125
|
-
return false;
|
|
126
|
-
}
|
|
127
|
-
if (Symbol.toStringTag in value) {
|
|
128
|
-
return Object.prototype.toString.call(value) === "[object Module]";
|
|
129
|
-
}
|
|
130
|
-
return true;
|
|
131
|
-
}
|
|
132
|
-
function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
133
|
-
if (!isPlainObject(defaults)) {
|
|
134
|
-
return _defu(baseObject, {}, namespace, merger);
|
|
135
|
-
}
|
|
136
|
-
const object = Object.assign({}, defaults);
|
|
137
|
-
for (const key in baseObject) {
|
|
138
|
-
if (key === "__proto__" || key === "constructor") {
|
|
139
|
-
continue;
|
|
140
|
-
}
|
|
141
|
-
const value = baseObject[key];
|
|
142
|
-
if (value === null || value === void 0) {
|
|
143
|
-
continue;
|
|
144
|
-
}
|
|
145
|
-
if (merger && merger(object, key, value, namespace)) {
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
148
|
-
if (Array.isArray(value) && Array.isArray(object[key])) {
|
|
149
|
-
object[key] = [...value, ...object[key]];
|
|
150
|
-
} else if (isPlainObject(value) && isPlainObject(object[key])) {
|
|
151
|
-
object[key] = _defu(
|
|
152
|
-
value,
|
|
153
|
-
object[key],
|
|
154
|
-
(namespace ? `${namespace}.` : "") + key.toString(),
|
|
155
|
-
merger
|
|
156
|
-
);
|
|
157
|
-
} else {
|
|
158
|
-
object[key] = value;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
return object;
|
|
162
|
-
}
|
|
163
|
-
function createDefu(merger) {
|
|
164
|
-
return (...arguments_) => (
|
|
165
|
-
// eslint-disable-next-line unicorn/no-array-reduce
|
|
166
|
-
arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
var defu = createDefu();
|
|
170
|
-
var defuFn = createDefu((object, key, currentValue) => {
|
|
171
|
-
if (object[key] !== void 0 && typeof currentValue === "function") {
|
|
172
|
-
object[key] = currentValue(object[key]);
|
|
173
|
-
return true;
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
var defuArrayFn = createDefu((object, key, currentValue) => {
|
|
177
|
-
if (Array.isArray(object[key]) && typeof currentValue === "function") {
|
|
178
|
-
object[key] = currentValue(object[key]);
|
|
179
|
-
return true;
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
// src/monorepo/workspace.ts
|
|
184
|
-
import path3 from "pathe";
|
|
185
|
-
async function getWorkspacePackages(cwd2, options) {
|
|
186
|
-
const posixCwd = path3.normalize(cwd2);
|
|
187
|
-
const { ignoreRootPackage, ignorePrivatePackage } = defu(options, {
|
|
188
|
-
ignoreRootPackage: true,
|
|
189
|
-
ignorePrivatePackage: true
|
|
190
|
-
});
|
|
191
|
-
const packages = await findWorkspacePackages(cwd2);
|
|
192
|
-
let pkgs = packages.filter((x) => {
|
|
193
|
-
if (ignorePrivatePackage && x.manifest.private) {
|
|
194
|
-
return false;
|
|
195
|
-
}
|
|
196
|
-
return true;
|
|
197
|
-
}).map((project) => {
|
|
198
|
-
const pkgJsonPath = path3.resolve(project.rootDir, "package.json");
|
|
199
|
-
return {
|
|
200
|
-
...project,
|
|
201
|
-
pkgJsonPath
|
|
202
|
-
};
|
|
203
|
-
});
|
|
204
|
-
if (ignoreRootPackage) {
|
|
205
|
-
pkgs = pkgs.filter((x) => {
|
|
206
|
-
return path3.normalize(
|
|
207
|
-
x.rootDir
|
|
208
|
-
) !== posixCwd;
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
return pkgs;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// src/monorepo/context.ts
|
|
215
|
-
import "@pnpm/types";
|
|
216
|
-
async function createContext(cwd2) {
|
|
217
|
-
const git = new GitClient();
|
|
218
|
-
const workspaceFilepath = path4.resolve(cwd2, "pnpm-workspace.yaml");
|
|
219
|
-
const projects = await getWorkspacePackages(cwd2);
|
|
220
|
-
return {
|
|
221
|
-
cwd: cwd2,
|
|
222
|
-
git,
|
|
223
|
-
workspaceFilepath,
|
|
224
|
-
projects
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
// src/monorepo/setPkgJson.ts
|
|
229
|
-
init_esm_shims();
|
|
230
|
-
var import_set_value2 = __toESM(require_set_value(), 1);
|
|
231
|
-
import fs3 from "fs-extra";
|
|
232
|
-
import path5 from "pathe";
|
|
233
|
-
async function setPkgJson_default(ctx) {
|
|
234
|
-
const { git, projects, cwd: cwd2, workspaceFilepath } = ctx;
|
|
235
|
-
const gitUrl = await git.getGitUrl();
|
|
236
|
-
const gitUser = await git.getUser();
|
|
237
|
-
if (gitUrl && await fs3.exists(workspaceFilepath)) {
|
|
238
|
-
for (const project of projects) {
|
|
239
|
-
const pkgJson = project.manifest;
|
|
240
|
-
const directory = path5.relative(cwd2, project.rootDir);
|
|
241
|
-
(0, import_set_value2.default)(pkgJson, "bugs.url", `https://github.com/${gitUrl.full_name}/issues`);
|
|
242
|
-
const repository = {
|
|
243
|
-
type: "git",
|
|
244
|
-
url: `git+https://github.com/${gitUrl.full_name}.git`
|
|
245
|
-
};
|
|
246
|
-
if (directory) {
|
|
247
|
-
repository.directory = directory;
|
|
248
|
-
}
|
|
249
|
-
(0, import_set_value2.default)(pkgJson, "repository", repository);
|
|
250
|
-
if (gitUser) {
|
|
251
|
-
(0, import_set_value2.default)(pkgJson, "author", `${gitUser.name} <${gitUser.email}>`);
|
|
252
|
-
}
|
|
253
|
-
await fs3.writeJSON(project.pkgJsonPath, pkgJson, {
|
|
254
|
-
spaces: 2
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
// src/monorepo/setReadme.ts
|
|
261
|
-
init_esm_shims();
|
|
262
|
-
import fs4 from "fs-extra";
|
|
263
|
-
import path6 from "pathe";
|
|
264
|
-
async function getRows(ctx) {
|
|
265
|
-
const { projects, git, cwd: cwd2 } = ctx;
|
|
266
|
-
const gitUrl = await git.getGitUrl();
|
|
267
|
-
const gitUser = await git.getUser();
|
|
268
|
-
const rows = [];
|
|
269
|
-
if (gitUrl) {
|
|
270
|
-
rows.push(`# ${gitUrl.name}
|
|
271
|
-
`);
|
|
272
|
-
}
|
|
273
|
-
rows.push("## Projects\n");
|
|
274
|
-
for (const project of projects) {
|
|
275
|
-
const p = path6.relative(cwd2, project.rootDirRealPath);
|
|
276
|
-
p && rows.push(`- [${project.manifest.name}](${p}) ${project.manifest.description ? `- ${project.manifest.description}` : ""}`);
|
|
277
|
-
}
|
|
278
|
-
if (gitUrl) {
|
|
279
|
-
rows.push("\n## Contributing\n");
|
|
280
|
-
rows.push("Contributions Welcome! You can contribute in the following ways.");
|
|
281
|
-
rows.push("");
|
|
282
|
-
rows.push("- Create an Issue - Propose a new feature. Report a bug.");
|
|
283
|
-
rows.push("- Pull Request - Fix a bug and typo. Refactor the code.");
|
|
284
|
-
rows.push("- Create third-party middleware - Instruct below.");
|
|
285
|
-
rows.push("- Share - Share your thoughts on the Blog, X, and others.");
|
|
286
|
-
rows.push(`- Make your application - Please try to use ${gitUrl.name}.`);
|
|
287
|
-
rows.push("");
|
|
288
|
-
rows.push("For more details, see [CONTRIBUTING.md](CONTRIBUTING.md).");
|
|
289
|
-
rows.push("\n## Contributors\n");
|
|
290
|
-
rows.push(`Thanks to [all contributors](https://github.com/${gitUrl.full_name}/graphs/contributors)!`);
|
|
291
|
-
}
|
|
292
|
-
rows.push("\n## Authors\n");
|
|
293
|
-
rows.push(`${gitUser.name} <${gitUser.email}>`);
|
|
294
|
-
rows.push("\n## License\n");
|
|
295
|
-
rows.push("Distributed under the MIT License. See [LICENSE](LICENSE) for more information.");
|
|
296
|
-
return rows;
|
|
297
|
-
}
|
|
298
|
-
async function setReadme_default(ctx) {
|
|
299
|
-
const rows = await getRows(ctx);
|
|
300
|
-
await fs4.writeFile(path6.resolve(ctx.cwd, "README.md"), `${rows.join("\n")}
|
|
301
|
-
`);
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
// src/monorepo/init.ts
|
|
305
|
-
async function init(cwd2) {
|
|
306
|
-
const ctx = await createContext(cwd2);
|
|
307
|
-
await setPkgJson_default(ctx);
|
|
308
|
-
await setReadme_default(ctx);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
// src/monorepo/sync.ts
|
|
312
|
-
init_esm_shims();
|
|
313
|
-
import { execa } from "execa";
|
|
314
|
-
import pc from "picocolors";
|
|
315
|
-
async function syncNpmMirror(cwd2) {
|
|
316
|
-
const packages = await getWorkspacePackages(cwd2);
|
|
317
|
-
logger.info(`[\u5373\u5C06\u540C\u6B65\u7684\u5305]:
|
|
318
|
-
${packages.filter((x) => x.manifest.name).map((x) => `- ${pc.green(x.manifest.name)}`).join("\n")}
|
|
319
|
-
`);
|
|
320
|
-
for (const project of packages) {
|
|
321
|
-
if (project.manifest.name) {
|
|
322
|
-
await execa({
|
|
323
|
-
stdout: ["pipe", "inherit"]
|
|
324
|
-
})`cnpm sync ${project.manifest.name}`;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
// src/program.ts
|
|
330
21
|
var cwd = process.cwd();
|
|
331
22
|
program.name(name).version(version);
|
|
332
23
|
program.option("-i,--interactive").option("--raw", "raw mode").option("--outDir <dir>", "Output directory").action(async (opts) => {
|