@icebreakers/monorepo 3.2.4 → 3.2.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/cli.cjs +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.cjs +2 -1
- package/dist/index.d.cts +304 -4
- package/dist/index.d.mts +304 -4
- package/dist/index.mjs +1 -1
- package/dist/{upgrade-BI_dD_HR.cjs → upgrade-BpiSZThJ.cjs} +66 -66
- package/dist/{upgrade-BnOc9MKM.mjs → upgrade-C8CPHZxP.mjs} +86 -86
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -2,11 +2,10 @@ import * as git_url_parse0 from "git-url-parse";
|
|
|
2
2
|
import gitUrlParse from "git-url-parse";
|
|
3
3
|
import * as simple_git0 from "simple-git";
|
|
4
4
|
import { ConfigValues, SimpleGit, SimpleGitOptions } from "simple-git";
|
|
5
|
-
import * as
|
|
5
|
+
import * as consola from "consola";
|
|
6
6
|
import { TemplateDefinition, assetsDir, isGitignoreFile, templatesDir, toPublishGitignorePath, toWorkspaceGitignorePath } from "@icebreakers/monorepo-templates";
|
|
7
7
|
import * as _pnpm_types0 from "@pnpm/types";
|
|
8
8
|
import crypto from "node:crypto";
|
|
9
|
-
import { PackageJson } from "pkg-types";
|
|
10
9
|
|
|
11
10
|
//#region src/types/cli.d.ts
|
|
12
11
|
/**
|
|
@@ -385,6 +384,307 @@ interface MonorepoConfig {
|
|
|
385
384
|
};
|
|
386
385
|
}
|
|
387
386
|
//#endregion
|
|
387
|
+
//#region ../../node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.d.mts
|
|
388
|
+
interface PackageJson {
|
|
389
|
+
/**
|
|
390
|
+
* The name is what your thing is called.
|
|
391
|
+
* Some rules:
|
|
392
|
+
* - The name must be less than or equal to 214 characters. This includes the scope for scoped packages.
|
|
393
|
+
* - The name can’t start with a dot or an underscore.
|
|
394
|
+
* - New packages must not have uppercase letters in the name.
|
|
395
|
+
* - The name ends up being part of a URL, an argument on the command line, and a folder name. Therefore, the name can’t contain any non-URL-safe characters.
|
|
396
|
+
*/
|
|
397
|
+
name?: string;
|
|
398
|
+
/**
|
|
399
|
+
* Version must be parseable by `node-semver`, which is bundled with npm as a dependency. (`npm install semver` to use it yourself.)
|
|
400
|
+
*/
|
|
401
|
+
version?: string;
|
|
402
|
+
/**
|
|
403
|
+
* Put a description in it. It’s a string. This helps people discover your package, as it’s listed in `npm search`.
|
|
404
|
+
*/
|
|
405
|
+
description?: string;
|
|
406
|
+
/**
|
|
407
|
+
* Put keywords in it. It’s an array of strings. This helps people discover your package as it’s listed in `npm search`.
|
|
408
|
+
*/
|
|
409
|
+
keywords?: string[];
|
|
410
|
+
/**
|
|
411
|
+
* The url to the project homepage.
|
|
412
|
+
*/
|
|
413
|
+
homepage?: string;
|
|
414
|
+
/**
|
|
415
|
+
* The url to your project’s issue tracker and / or the email address to which issues should be reported. These are helpful for people who encounter issues with your package.
|
|
416
|
+
*/
|
|
417
|
+
bugs?: string | {
|
|
418
|
+
url?: string;
|
|
419
|
+
email?: string;
|
|
420
|
+
};
|
|
421
|
+
/**
|
|
422
|
+
* You should specify a license for your package so that people know how they are permitted to use it, and any restrictions you’re placing on it.
|
|
423
|
+
*/
|
|
424
|
+
license?: string;
|
|
425
|
+
/**
|
|
426
|
+
* Specify the place where your code lives. This is helpful for people who want to contribute. If the git repo is on GitHub, then the `npm docs` command will be able to find you.
|
|
427
|
+
* For GitHub, GitHub gist, Bitbucket, or GitLab repositories you can use the same shortcut syntax you use for npm install:
|
|
428
|
+
*/
|
|
429
|
+
repository?: string | {
|
|
430
|
+
type: string;
|
|
431
|
+
url: string;
|
|
432
|
+
/**
|
|
433
|
+
* If the `package.json` for your package is not in the root directory (for example if it is part of a monorepo), you can specify the directory in which it lives:
|
|
434
|
+
*/
|
|
435
|
+
directory?: string;
|
|
436
|
+
};
|
|
437
|
+
/**
|
|
438
|
+
* The `scripts` field is a dictionary containing script commands that are run at various times in the lifecycle of your package.
|
|
439
|
+
*/
|
|
440
|
+
scripts?: PackageJsonScripts;
|
|
441
|
+
/**
|
|
442
|
+
* If you set `"private": true` in your package.json, then npm will refuse to publish it.
|
|
443
|
+
*/
|
|
444
|
+
private?: boolean;
|
|
445
|
+
/**
|
|
446
|
+
* The “author” is one person.
|
|
447
|
+
*/
|
|
448
|
+
author?: PackageJsonPerson;
|
|
449
|
+
/**
|
|
450
|
+
* “contributors” is an array of people.
|
|
451
|
+
*/
|
|
452
|
+
contributors?: PackageJsonPerson[];
|
|
453
|
+
/**
|
|
454
|
+
* An object containing a URL that provides up-to-date information
|
|
455
|
+
* about ways to help fund development of your package,
|
|
456
|
+
* a string URL, or an array of objects and string URLs
|
|
457
|
+
*/
|
|
458
|
+
funding?: PackageJsonFunding | PackageJsonFunding[];
|
|
459
|
+
/**
|
|
460
|
+
* The optional `files` field is an array of file patterns that describes the entries to be included when your package is installed as a dependency. File patterns follow a similar syntax to `.gitignore`, but reversed: including a file, directory, or glob pattern (`*`, `**\/*`, and such) will make it so that file is included in the tarball when it’s packed. Omitting the field will make it default to `["*"]`, which means it will include all files.
|
|
461
|
+
*/
|
|
462
|
+
files?: string[];
|
|
463
|
+
/**
|
|
464
|
+
* The main field is a module ID that is the primary entry point to your program. That is, if your package is named `foo`, and a user installs it, and then does `require("foo")`, then your main module’s exports object will be returned.
|
|
465
|
+
* This should be a module ID relative to the root of your package folder.
|
|
466
|
+
* For most modules, it makes the most sense to have a main script and often not much else.
|
|
467
|
+
*/
|
|
468
|
+
main?: string;
|
|
469
|
+
/**
|
|
470
|
+
* If your module is meant to be used client-side the browser field should be used instead of the main field. This is helpful to hint users that it might rely on primitives that aren’t available in Node.js modules. (e.g. window)
|
|
471
|
+
*/
|
|
472
|
+
browser?: string | Record<string, string | false>;
|
|
473
|
+
/**
|
|
474
|
+
* The `unpkg` field is used to specify the URL to a UMD module for your package. This is used by default in the unpkg.com CDN service.
|
|
475
|
+
*/
|
|
476
|
+
unpkg?: string;
|
|
477
|
+
/**
|
|
478
|
+
* A map of command name to local file name. On install, npm will symlink that file into `prefix/bin` for global installs, or `./node_modules/.bin/` for local installs.
|
|
479
|
+
*/
|
|
480
|
+
bin?: string | Record<string, string>;
|
|
481
|
+
/**
|
|
482
|
+
* Specify either a single file or an array of filenames to put in place for the `man` program to find.
|
|
483
|
+
*/
|
|
484
|
+
man?: string | string[];
|
|
485
|
+
/**
|
|
486
|
+
* Dependencies are specified in a simple object that maps a package name to a version range. The version range is a string which has one or more space-separated descriptors. Dependencies can also be identified with a tarball or git URL.
|
|
487
|
+
*/
|
|
488
|
+
dependencies?: Record<string, string>;
|
|
489
|
+
/**
|
|
490
|
+
* If someone is planning on downloading and using your module in their program, then they probably don’t want or need to download and build the external test or documentation framework that you use.
|
|
491
|
+
* In this case, it’s best to map these additional items in a `devDependencies` object.
|
|
492
|
+
*/
|
|
493
|
+
devDependencies?: Record<string, string>;
|
|
494
|
+
/**
|
|
495
|
+
* If a dependency can be used, but you would like npm to proceed if it cannot be found or fails to install, then you may put it in the `optionalDependencies` object. This is a map of package name to version or url, just like the `dependencies` object. The difference is that build failures do not cause installation to fail.
|
|
496
|
+
*/
|
|
497
|
+
optionalDependencies?: Record<string, string>;
|
|
498
|
+
/**
|
|
499
|
+
* In some cases, you want to express the compatibility of your package with a host tool or library, while not necessarily doing a `require` of this host. This is usually referred to as a plugin. Notably, your module may be exposing a specific interface, expected and specified by the host documentation.
|
|
500
|
+
*/
|
|
501
|
+
peerDependencies?: Record<string, string>;
|
|
502
|
+
/**
|
|
503
|
+
* TypeScript typings, typically ending by `.d.ts`.
|
|
504
|
+
*/
|
|
505
|
+
types?: string;
|
|
506
|
+
/**
|
|
507
|
+
* This field is synonymous with `types`.
|
|
508
|
+
*/
|
|
509
|
+
typings?: string;
|
|
510
|
+
/**
|
|
511
|
+
* Non-Standard Node.js alternate entry-point to main.
|
|
512
|
+
* An initial implementation for supporting CJS packages (from main), and use module for ESM modules.
|
|
513
|
+
*/
|
|
514
|
+
module?: string;
|
|
515
|
+
/**
|
|
516
|
+
* Make main entry-point be loaded as an ESM module, support "export" syntax instead of "require"
|
|
517
|
+
*
|
|
518
|
+
* Docs:
|
|
519
|
+
* - https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_package_json_type_field
|
|
520
|
+
*
|
|
521
|
+
* @default 'commonjs'
|
|
522
|
+
* @since Node.js v14
|
|
523
|
+
*/
|
|
524
|
+
type?: "module" | "commonjs";
|
|
525
|
+
/**
|
|
526
|
+
* Alternate and extensible alternative to "main" entry point.
|
|
527
|
+
*
|
|
528
|
+
* When using `{type: "module"}`, any ESM module file MUST end with `.mjs` extension.
|
|
529
|
+
*
|
|
530
|
+
* Docs:
|
|
531
|
+
* - https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_exports_sugar
|
|
532
|
+
*
|
|
533
|
+
* @since Node.js v12.7
|
|
534
|
+
*/
|
|
535
|
+
exports?: PackageJsonExports;
|
|
536
|
+
/**
|
|
537
|
+
* Docs:
|
|
538
|
+
* - https://nodejs.org/api/packages.html#imports
|
|
539
|
+
*/
|
|
540
|
+
imports?: Record<string, string | Record<string, string>>;
|
|
541
|
+
/**
|
|
542
|
+
* The field is used to define a set of sub-packages (or workspaces) within a monorepo.
|
|
543
|
+
*
|
|
544
|
+
* This field is an array of glob patterns or an object with specific configurations for managing
|
|
545
|
+
* multiple packages in a single repository.
|
|
546
|
+
*/
|
|
547
|
+
workspaces?: string[] | {
|
|
548
|
+
/**
|
|
549
|
+
* Workspace package paths. Glob patterns are supported.
|
|
550
|
+
*/
|
|
551
|
+
packages?: string[];
|
|
552
|
+
/**
|
|
553
|
+
* Packages to block from hoisting to the workspace root.
|
|
554
|
+
* Uses glob patterns to match module paths in the dependency tree.
|
|
555
|
+
*
|
|
556
|
+
* Docs:
|
|
557
|
+
* - https://classic.yarnpkg.com/blog/2018/02/15/nohoist/
|
|
558
|
+
*/
|
|
559
|
+
nohoist?: string[];
|
|
560
|
+
};
|
|
561
|
+
/**
|
|
562
|
+
* The field is used to specify different TypeScript declaration files for
|
|
563
|
+
* different versions of TypeScript, allowing for version-specific type definitions.
|
|
564
|
+
*/
|
|
565
|
+
typesVersions?: Record<string, Record<string, string[]>>;
|
|
566
|
+
/**
|
|
567
|
+
* You can specify which operating systems your module will run on:
|
|
568
|
+
* ```json
|
|
569
|
+
* {
|
|
570
|
+
* "os": ["darwin", "linux"]
|
|
571
|
+
* }
|
|
572
|
+
* ```
|
|
573
|
+
* You can also block instead of allowing operating systems, just prepend the blocked os with a '!':
|
|
574
|
+
* ```json
|
|
575
|
+
* {
|
|
576
|
+
* "os": ["!win32"]
|
|
577
|
+
* }
|
|
578
|
+
* ```
|
|
579
|
+
* The host operating system is determined by `process.platform`
|
|
580
|
+
* It is allowed to both block and allow an item, although there isn't any good reason to do this.
|
|
581
|
+
*/
|
|
582
|
+
os?: string[];
|
|
583
|
+
/**
|
|
584
|
+
* If your code only runs on certain cpu architectures, you can specify which ones.
|
|
585
|
+
* ```json
|
|
586
|
+
* {
|
|
587
|
+
* "cpu": ["x64", "ia32"]
|
|
588
|
+
* }
|
|
589
|
+
* ```
|
|
590
|
+
* Like the `os` option, you can also block architectures:
|
|
591
|
+
* ```json
|
|
592
|
+
* {
|
|
593
|
+
* "cpu": ["!arm", "!mips"]
|
|
594
|
+
* }
|
|
595
|
+
* ```
|
|
596
|
+
* The host architecture is determined by `process.arch`
|
|
597
|
+
*/
|
|
598
|
+
cpu?: string[];
|
|
599
|
+
/**
|
|
600
|
+
* This is a set of config values that will be used at publish-time.
|
|
601
|
+
*/
|
|
602
|
+
publishConfig?: {
|
|
603
|
+
/**
|
|
604
|
+
* The registry that will be used if the package is published.
|
|
605
|
+
*/
|
|
606
|
+
registry?: string;
|
|
607
|
+
/**
|
|
608
|
+
* The tag that will be used if the package is published.
|
|
609
|
+
*/
|
|
610
|
+
tag?: string;
|
|
611
|
+
/**
|
|
612
|
+
* The access level that will be used if the package is published.
|
|
613
|
+
*/
|
|
614
|
+
access?: "public" | "restricted";
|
|
615
|
+
/**
|
|
616
|
+
* **pnpm-only**
|
|
617
|
+
*
|
|
618
|
+
* By default, for portability reasons, no files except those listed in
|
|
619
|
+
* the bin field will be marked as executable in the resulting package
|
|
620
|
+
* archive. The executableFiles field lets you declare additional fields
|
|
621
|
+
* that must have the executable flag (+x) set even if
|
|
622
|
+
* they aren't directly accessible through the bin field.
|
|
623
|
+
*/
|
|
624
|
+
executableFiles?: string[];
|
|
625
|
+
/**
|
|
626
|
+
* **pnpm-only**
|
|
627
|
+
*
|
|
628
|
+
* You also can use the field `publishConfig.directory` to customize
|
|
629
|
+
* the published subdirectory relative to the current `package.json`.
|
|
630
|
+
*
|
|
631
|
+
* It is expected to have a modified version of the current package in
|
|
632
|
+
* the specified directory (usually using third party build tools).
|
|
633
|
+
*/
|
|
634
|
+
directory?: string;
|
|
635
|
+
/**
|
|
636
|
+
* **pnpm-only**
|
|
637
|
+
*
|
|
638
|
+
* When set to `true`, the project will be symlinked from the
|
|
639
|
+
* `publishConfig.directory` location during local development.
|
|
640
|
+
* @default true
|
|
641
|
+
*/
|
|
642
|
+
linkDirectory?: boolean;
|
|
643
|
+
} & Pick<PackageJson, "bin" | "main" | "exports" | "types" | "typings" | "module" | "browser" | "unpkg" | "typesVersions" | "os" | "cpu">;
|
|
644
|
+
/**
|
|
645
|
+
* See: https://nodejs.org/api/packages.html#packagemanager
|
|
646
|
+
* This field defines which package manager is expected to be used when working on the current project.
|
|
647
|
+
* Should be of the format: `<name>@<version>[#hash]`
|
|
648
|
+
*/
|
|
649
|
+
packageManager?: string;
|
|
650
|
+
[key: string]: any;
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* See: https://docs.npmjs.com/cli/v11/using-npm/scripts#pre--post-scripts
|
|
654
|
+
*/
|
|
655
|
+
type PackageJsonScriptWithPreAndPost<S extends string> = S | `${"pre" | "post"}${S}`;
|
|
656
|
+
/**
|
|
657
|
+
* See: https://docs.npmjs.com/cli/v11/using-npm/scripts#life-cycle-operation-order
|
|
658
|
+
*/
|
|
659
|
+
type PackageJsonNpmLifeCycleScripts = "dependencies" | "prepublishOnly" | PackageJsonScriptWithPreAndPost<"install" | "pack" | "prepare" | "publish" | "restart" | "start" | "stop" | "test" | "version">;
|
|
660
|
+
/**
|
|
661
|
+
* See: https://pnpm.io/scripts#lifecycle-scripts
|
|
662
|
+
*/
|
|
663
|
+
type PackageJsonPnpmLifeCycleScripts = "pnpm:devPreinstall";
|
|
664
|
+
type PackageJsonCommonScripts = "build" | "coverage" | "deploy" | "dev" | "format" | "lint" | "preview" | "release" | "typecheck" | "watch";
|
|
665
|
+
type PackageJsonScriptName = PackageJsonCommonScripts | PackageJsonNpmLifeCycleScripts | PackageJsonPnpmLifeCycleScripts | (string & {});
|
|
666
|
+
type PackageJsonScripts = { [P in PackageJsonScriptName]?: string };
|
|
667
|
+
/**
|
|
668
|
+
* A “person” is an object with a “name” field and optionally “url” and “email”. Or you can shorten that all into a single string, and npm will parse it for you.
|
|
669
|
+
*/
|
|
670
|
+
type PackageJsonPerson = string | {
|
|
671
|
+
name: string;
|
|
672
|
+
email?: string;
|
|
673
|
+
url?: string;
|
|
674
|
+
};
|
|
675
|
+
type PackageJsonFunding = string | {
|
|
676
|
+
url: string;
|
|
677
|
+
type?: string;
|
|
678
|
+
};
|
|
679
|
+
type PackageJsonExportKey = "." | "import" | "require" | "types" | "node" | "browser" | "default" | (string & {});
|
|
680
|
+
type PackageJsonExportsObject = { [P in PackageJsonExportKey]?: string | PackageJsonExportsObject | Array<string | PackageJsonExportsObject> };
|
|
681
|
+
type PackageJsonExports = string | PackageJsonExportsObject | Array<string | PackageJsonExportsObject>;
|
|
682
|
+
/**
|
|
683
|
+
* Defines a PackageJson structure.
|
|
684
|
+
* @param pkg - The `package.json` content as an object. See {@link PackageJson}.
|
|
685
|
+
* @returns the same `package.json` object.
|
|
686
|
+
*/
|
|
687
|
+
//#endregion
|
|
388
688
|
//#region src/commands/skills.d.ts
|
|
389
689
|
declare const skillTargets: readonly ["codex", "claude"];
|
|
390
690
|
type SkillTarget = typeof skillTargets[number];
|
|
@@ -497,7 +797,7 @@ declare function syncNpmMirror(cwd: string, options?: GetWorkspacePackagesOption
|
|
|
497
797
|
*/
|
|
498
798
|
declare function upgradeMonorepo(opts: CliOpts): Promise<void>;
|
|
499
799
|
//#endregion
|
|
500
|
-
//#region package.d.ts
|
|
800
|
+
//#region package.json.d.ts
|
|
501
801
|
declare let name: string;
|
|
502
802
|
declare let version: string;
|
|
503
803
|
//#endregion
|
|
@@ -558,7 +858,7 @@ type Context = Awaited<ReturnType<typeof createContext>>;
|
|
|
558
858
|
/**
|
|
559
859
|
* 统一的日志实例,便于在命令行中输出带有前缀和颜色的消息。
|
|
560
860
|
*/
|
|
561
|
-
declare const logger:
|
|
861
|
+
declare const logger: consola.ConsolaInstance;
|
|
562
862
|
//#endregion
|
|
563
863
|
//#region src/utils/fs.d.ts
|
|
564
864
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as defineMonorepoConfig, B as getWorkspacePackages, C as syncSkills, D as templatesDir, E as rootDir, F as generateAgenticTemplate, I as generateAgenticTemplates, L as loadAgenticTasks, M as resolveCommandConfig, N as createTimestampFolderName, O as name, P as defaultAgenticBaseDir, R as logger, S as skillTargets, T as packageDir, V as GitClient, _ as getCreateChoices, a as escapeStringRegexp, b as cleanProjects, c as isFileChanged, d as toWorkspaceGitignorePath, f as updateIssueTemplateConfig, h as createNewProject, i as init, j as loadMonorepoConfig, k as version, l as isGitignoreFile, m as createContext, n as syncNpmMirror, o as isMatch, p as isIgnorableFsError, r as setVscodeBinaryMirror, s as getFileHash, t as upgradeMonorepo, u as toPublishGitignorePath, v as getTemplateMap, w as assetsDir, x as getSkillTargetPaths, y as templateMap, z as getWorkspaceData } from "./upgrade-
|
|
1
|
+
import { A as defineMonorepoConfig, B as getWorkspacePackages, C as syncSkills, D as templatesDir, E as rootDir, F as generateAgenticTemplate, I as generateAgenticTemplates, L as loadAgenticTasks, M as resolveCommandConfig, N as createTimestampFolderName, O as name, P as defaultAgenticBaseDir, R as logger, S as skillTargets, T as packageDir, V as GitClient, _ as getCreateChoices, a as escapeStringRegexp, b as cleanProjects, c as isFileChanged, d as toWorkspaceGitignorePath, f as updateIssueTemplateConfig, h as createNewProject, i as init, j as loadMonorepoConfig, k as version, l as isGitignoreFile, m as createContext, n as syncNpmMirror, o as isMatch, p as isIgnorableFsError, r as setVscodeBinaryMirror, s as getFileHash, t as upgradeMonorepo, u as toPublishGitignorePath, v as getTemplateMap, w as assetsDir, x as getSkillTargetPaths, y as templateMap, z as getWorkspaceData } from "./upgrade-C8CPHZxP.mjs";
|
|
2
2
|
|
|
3
3
|
export { GitClient, assetsDir, cleanProjects, createContext, createNewProject, createTimestampFolderName, defaultAgenticBaseDir, defineMonorepoConfig, escapeStringRegexp, generateAgenticTemplate, generateAgenticTemplates, getCreateChoices, getFileHash, getSkillTargetPaths, getTemplateMap, getWorkspaceData, getWorkspacePackages, init, isFileChanged, isGitignoreFile, isIgnorableFsError, isMatch, loadAgenticTasks, loadMonorepoConfig, logger, name, packageDir, resolveCommandConfig, rootDir, setVscodeBinaryMirror, skillTargets, syncNpmMirror, syncSkills, templateMap, templatesDir, toPublishGitignorePath, toWorkspaceGitignorePath, updateIssueTemplateConfig, upgradeMonorepo, version };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp$1 = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -72,9 +72,9 @@ var join = /* @__PURE__ */ __name((segs, joinChar, options) => {
|
|
|
72
72
|
if (typeof options.join === "function") return options.join(segs);
|
|
73
73
|
return segs[0] + joinChar + segs[1];
|
|
74
74
|
}, "join");
|
|
75
|
-
var split = /* @__PURE__ */ __name((path
|
|
76
|
-
if (typeof options.split === "function") return options.split(path
|
|
77
|
-
return path
|
|
75
|
+
var split = /* @__PURE__ */ __name((path, splitChar, options) => {
|
|
76
|
+
if (typeof options.split === "function") return options.split(path);
|
|
77
|
+
return path.split(splitChar);
|
|
78
78
|
}, "split");
|
|
79
79
|
var isValid = /* @__PURE__ */ __name((key, target = {}, options) => {
|
|
80
80
|
if (typeof options?.isValid === "function") return options.isValid(key, target);
|
|
@@ -83,17 +83,17 @@ var isValid = /* @__PURE__ */ __name((key, target = {}, options) => {
|
|
|
83
83
|
var isValidObject = /* @__PURE__ */ __name((v) => {
|
|
84
84
|
return isObject(v) || typeof v === "function";
|
|
85
85
|
}, "isValidObject");
|
|
86
|
-
var index_default = /* @__PURE__ */ __name((target, path
|
|
86
|
+
var index_default = /* @__PURE__ */ __name((target, path, options = {}) => {
|
|
87
87
|
if (!isObject(options)) options = { default: options };
|
|
88
88
|
if (!isValidObject(target)) return typeof options.default !== "undefined" ? options.default : target;
|
|
89
|
-
if (typeof path
|
|
90
|
-
const pathIsArray = Array.isArray(path
|
|
91
|
-
const pathIsString = typeof path
|
|
89
|
+
if (typeof path === "number") path = String(path);
|
|
90
|
+
const pathIsArray = Array.isArray(path);
|
|
91
|
+
const pathIsString = typeof path === "string";
|
|
92
92
|
const splitChar = options.separator || ".";
|
|
93
93
|
const joinChar = options.joinChar || (typeof splitChar === "string" ? splitChar : ".");
|
|
94
94
|
if (!pathIsString && !pathIsArray) return target;
|
|
95
|
-
if (target[path
|
|
96
|
-
const segs = pathIsArray ? path
|
|
95
|
+
if (target[path] !== void 0) return isValid(path, target, options) ? target[path] : options.default;
|
|
96
|
+
const segs = pathIsArray ? path : split(path, splitChar, options);
|
|
97
97
|
const len = segs.length;
|
|
98
98
|
let idx = 0;
|
|
99
99
|
do {
|
|
@@ -378,7 +378,7 @@ var require_is_primitive = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
378
378
|
* Released under the MIT License.
|
|
379
379
|
*/
|
|
380
380
|
var require_isobject = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
381
|
-
module.exports = function isObject
|
|
381
|
+
module.exports = function isObject(val) {
|
|
382
382
|
return val != null && typeof val === "object" && Array.isArray(val) === false;
|
|
383
383
|
};
|
|
384
384
|
}));
|
|
@@ -396,7 +396,7 @@ var require_is_plain_object = /* @__PURE__ */ __commonJSMin(((exports, module) =
|
|
|
396
396
|
function isObjectObject(o) {
|
|
397
397
|
return isObject(o) === true && Object.prototype.toString.call(o) === "[object Object]";
|
|
398
398
|
}
|
|
399
|
-
module.exports = function isPlainObject
|
|
399
|
+
module.exports = function isPlainObject(o) {
|
|
400
400
|
var ctor, prot;
|
|
401
401
|
if (isObjectObject(o) === false) return false;
|
|
402
402
|
ctor = o.constructor;
|
|
@@ -456,10 +456,10 @@ var require_set_value = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
456
456
|
if (typeof input === "string" && preserve !== false && /\//.test(input)) return [input];
|
|
457
457
|
const parts = [];
|
|
458
458
|
let part = "";
|
|
459
|
-
const push = (part
|
|
459
|
+
const push = (part) => {
|
|
460
460
|
let number;
|
|
461
|
-
if (part
|
|
462
|
-
else parts.push(part
|
|
461
|
+
if (part.trim() !== "" && Number.isInteger(number = Number(part))) parts.push(number);
|
|
462
|
+
else parts.push(part);
|
|
463
463
|
};
|
|
464
464
|
for (let i = 0; i < input.length; i++) {
|
|
465
465
|
const value = input[i];
|
|
@@ -493,9 +493,9 @@ var require_set_value = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
493
493
|
} else obj[prop] = value;
|
|
494
494
|
return obj;
|
|
495
495
|
};
|
|
496
|
-
const setValue = (target, path
|
|
497
|
-
if (!path
|
|
498
|
-
const keys = split(path
|
|
496
|
+
const setValue = (target, path, value, options) => {
|
|
497
|
+
if (!path || !isObject(target)) return target;
|
|
498
|
+
const keys = split(path, options);
|
|
499
499
|
let obj = target;
|
|
500
500
|
for (let i = 0; i < keys.length; i++) {
|
|
501
501
|
const key = keys[i];
|
|
@@ -563,14 +563,14 @@ async function loadMonorepoConfig(cwd) {
|
|
|
563
563
|
/**
|
|
564
564
|
* 获取命令对应的合并配置,若未配置则返回空对象,保证调用端逻辑简单。
|
|
565
565
|
*/
|
|
566
|
-
async function resolveCommandConfig(name
|
|
567
|
-
return ((await loadMonorepoConfig(cwd)).commands ?? {})[name
|
|
566
|
+
async function resolveCommandConfig(name, cwd) {
|
|
567
|
+
return ((await loadMonorepoConfig(cwd)).commands ?? {})[name] ?? {};
|
|
568
568
|
}
|
|
569
569
|
|
|
570
570
|
//#endregion
|
|
571
571
|
//#region package.json
|
|
572
572
|
var name = "@icebreakers/monorepo";
|
|
573
|
-
var version = "3.2.
|
|
573
|
+
var version = "3.2.6";
|
|
574
574
|
|
|
575
575
|
//#endregion
|
|
576
576
|
//#region src/constants.ts
|
|
@@ -652,10 +652,10 @@ async function cleanProjects(cwd, overrides) {
|
|
|
652
652
|
const cleanConfig = mergeCleanConfig(await resolveCommandConfig("clean", cwd), overrides);
|
|
653
653
|
const { packages, workspaceDir } = await getWorkspaceData(cwd, cleanConfig?.includePrivate ?? true ? { ignorePrivatePackage: false } : void 0);
|
|
654
654
|
const filteredPackages = packages.filter((pkg) => {
|
|
655
|
-
const name
|
|
656
|
-
if (!name
|
|
655
|
+
const name = pkg.manifest.name ?? "";
|
|
656
|
+
if (!name) return true;
|
|
657
657
|
if (!cleanConfig?.ignorePackages?.length) return true;
|
|
658
|
-
return !cleanConfig.ignorePackages.includes(name
|
|
658
|
+
return !cleanConfig.ignorePackages.includes(name);
|
|
659
659
|
});
|
|
660
660
|
let cleanDirs = [];
|
|
661
661
|
if (cleanConfig?.autoConfirm) cleanDirs = filteredPackages.map((pkg) => pkg.rootDir);
|
|
@@ -675,20 +675,20 @@ async function cleanProjects(cwd, overrides) {
|
|
|
675
675
|
});
|
|
676
676
|
const readmeZh = pathe.default.resolve(workspaceDir, "README.zh-CN.md");
|
|
677
677
|
const qoderDir = pathe.default.resolve(workspaceDir, ".qoder");
|
|
678
|
-
const skillTargets
|
|
678
|
+
const skillTargets = Object.values(getSkillTargetPaths());
|
|
679
679
|
const candidates = Array.from(new Set([
|
|
680
680
|
...cleanDirs.filter(Boolean),
|
|
681
681
|
readmeZh,
|
|
682
682
|
qoderDir,
|
|
683
|
-
...skillTargets
|
|
683
|
+
...skillTargets
|
|
684
684
|
]));
|
|
685
685
|
await Promise.all(candidates.map(async (dir) => {
|
|
686
686
|
if (await fs_extra.default.pathExists(dir)) await fs_extra.default.remove(dir);
|
|
687
687
|
}));
|
|
688
|
-
const name
|
|
689
|
-
const pkgJson = await fs_extra.default.readJson(name
|
|
688
|
+
const name = pathe.default.resolve(workspaceDir, "package.json");
|
|
689
|
+
const pkgJson = await fs_extra.default.readJson(name);
|
|
690
690
|
(0, import_set_value.default)(pkgJson, "devDependencies.@icebreakers/monorepo", cleanConfig?.pinnedVersion ?? "latest", { preservePaths: false });
|
|
691
|
-
await fs_extra.default.outputJson(name
|
|
691
|
+
await fs_extra.default.outputJson(name, pkgJson, { spaces: 2 });
|
|
692
692
|
}
|
|
693
693
|
|
|
694
694
|
//#endregion
|
|
@@ -816,7 +816,7 @@ async function createNewProject(options) {
|
|
|
816
816
|
const createConfig = await resolveCommandConfig("create", cwd);
|
|
817
817
|
const renameJson = options?.renameJson ?? createConfig?.renameJson ?? false;
|
|
818
818
|
const rawName = options?.name ?? createConfig?.name;
|
|
819
|
-
const name
|
|
819
|
+
const name = typeof rawName === "string" ? rawName.trim() : void 0;
|
|
820
820
|
const requestedTemplate = options?.type ?? createConfig?.type ?? createConfig?.defaultTemplate ?? defaultTemplate;
|
|
821
821
|
const templateDefinitions = getTemplateMap(createConfig?.templateMap);
|
|
822
822
|
const templatesRoot = createConfig?.templatesDir ? pathe.default.resolve(cwd, createConfig.templatesDir) : _icebreakers_monorepo_templates.templatesDir;
|
|
@@ -825,7 +825,7 @@ async function createNewProject(options) {
|
|
|
825
825
|
const templateDefinition = templateDefinitions[bundlerName];
|
|
826
826
|
if (!templateDefinition) throw new Error(`未找到名为 ${bundlerName} 的模板,请检查 monorepo.config.ts`);
|
|
827
827
|
const from = pathe.default.join(templatesRoot, templateDefinition.source);
|
|
828
|
-
const targetName = name
|
|
828
|
+
const targetName = name && name.length > 0 ? name : templateDefinition.target;
|
|
829
829
|
const to = pathe.default.join(cwd, targetName);
|
|
830
830
|
if (await fs_extra.default.pathExists(to)) throw new Error(`${picocolors.default.red("目标目录已存在")}: ${pathe.default.relative(cwd, to)}`);
|
|
831
831
|
await fs_extra.default.ensureDir(to);
|
|
@@ -839,7 +839,7 @@ async function createNewProject(options) {
|
|
|
839
839
|
if (hasPackageJson) {
|
|
840
840
|
const sourceJson = await fs_extra.default.readJson(sourceJsonPath);
|
|
841
841
|
(0, import_set_value.default)(sourceJson, "version", "0.0.0");
|
|
842
|
-
(0, import_set_value.default)(sourceJson, "name", name
|
|
842
|
+
(0, import_set_value.default)(sourceJson, "name", name?.startsWith("@") ? name : pathe.default.basename(targetName));
|
|
843
843
|
await applyGitMetadata(sourceJson, cwd, to);
|
|
844
844
|
await fs_extra.default.outputJson(pathe.default.resolve(to, renameJson ? "package.mock.json" : "package.json"), sourceJson, { spaces: 2 });
|
|
845
845
|
}
|
|
@@ -1154,15 +1154,15 @@ async function syncNpmMirror(cwd, options) {
|
|
|
1154
1154
|
...options ?? {}
|
|
1155
1155
|
});
|
|
1156
1156
|
logger.info(`[当前工作区Repo]:\n${packages.map((x) => `- ${picocolors.default.green(x.manifest.name)} : ${pathe.default.relative(workspaceDir, x.rootDir)}`).join("\n")}\n`);
|
|
1157
|
-
const set
|
|
1157
|
+
const set = new Set(packages.map((x) => x.manifest.name));
|
|
1158
1158
|
if (packageFilter?.length) {
|
|
1159
|
-
for (const name
|
|
1159
|
+
for (const name of Array.from(set)) if (!name || !packageFilter.includes(name)) set.delete(name);
|
|
1160
1160
|
}
|
|
1161
|
-
logger.info(`[即将同步的包]:\n${Array.from(set
|
|
1161
|
+
logger.info(`[即将同步的包]:\n${Array.from(set).map((x) => `- ${picocolors.default.green(x ?? "")}`).join("\n")}\n`);
|
|
1162
1162
|
const queue = new p_queue.default({ concurrency: configConcurrency ?? Math.max(node_os.default.cpus().length, 1) });
|
|
1163
1163
|
const template = configCommand ?? "cnpm sync {name}";
|
|
1164
1164
|
const tasks = [];
|
|
1165
|
-
for (const pkgName of set
|
|
1165
|
+
for (const pkgName of set) {
|
|
1166
1166
|
if (!pkgName) continue;
|
|
1167
1167
|
tasks.push(queue.add(async () => {
|
|
1168
1168
|
return (0, _icebreakers_monorepo_templates.execaCommand)(renderCommand(template, pkgName), { stdio: "inherit" });
|
|
@@ -1261,9 +1261,9 @@ function parseVersion(input) {
|
|
|
1261
1261
|
return null;
|
|
1262
1262
|
}
|
|
1263
1263
|
}
|
|
1264
|
-
function hasNonOverridablePrefix(version
|
|
1265
|
-
if (typeof version
|
|
1266
|
-
return NON_OVERRIDABLE_PREFIXES.some((prefix) => version
|
|
1264
|
+
function hasNonOverridablePrefix(version) {
|
|
1265
|
+
if (typeof version !== "string") return false;
|
|
1266
|
+
return NON_OVERRIDABLE_PREFIXES.some((prefix) => version.startsWith(prefix));
|
|
1267
1267
|
}
|
|
1268
1268
|
function shouldAssignVersion(currentVersion, nextVersion) {
|
|
1269
1269
|
if (typeof currentVersion !== "string" || currentVersion.trim().length === 0) return true;
|
|
@@ -1308,9 +1308,9 @@ function setPkgJson(sourcePkgJson, targetPkgJson, options) {
|
|
|
1308
1308
|
if (Object.keys(targetDevDeps).length) targetPkgJson.devDependencies = targetDevDeps;
|
|
1309
1309
|
const scriptPairs = options?.scripts ? Object.entries(options.scripts) : scriptsEntries;
|
|
1310
1310
|
if (scriptPairs.length) {
|
|
1311
|
-
const scripts
|
|
1312
|
-
for (const [scriptName, scriptCmd] of scriptPairs) scripts
|
|
1313
|
-
targetPkgJson.scripts = scripts
|
|
1311
|
+
const scripts = { ...targetPkgJson.scripts ?? {} };
|
|
1312
|
+
for (const [scriptName, scriptCmd] of scriptPairs) scripts[scriptName] = scriptCmd;
|
|
1313
|
+
targetPkgJson.scripts = scripts;
|
|
1314
1314
|
}
|
|
1315
1315
|
}
|
|
1316
1316
|
|
|
@@ -1403,7 +1403,7 @@ async function upgradeMonorepo(opts) {
|
|
|
1403
1403
|
})
|
|
1404
1404
|
});
|
|
1405
1405
|
const regexpArr = targets.map((x) => {
|
|
1406
|
-
return
|
|
1406
|
+
return new RegExp(`^${escapeStringRegexp(x)}`);
|
|
1407
1407
|
});
|
|
1408
1408
|
const skipChangesetMarkdown = upgradeConfig?.skipChangesetMarkdown ?? true;
|
|
1409
1409
|
const scriptOverrides = upgradeConfig?.scripts;
|
|
@@ -1429,15 +1429,15 @@ async function upgradeMonorepo(opts) {
|
|
|
1429
1429
|
const targetPkgJson = await fs_extra.default.readJson(targetPath);
|
|
1430
1430
|
setPkgJson(sourcePkgJson, targetPkgJson, scriptOverrides ? { scripts: scriptOverrides } : void 0);
|
|
1431
1431
|
const data = `${JSON.stringify(targetPkgJson, void 0, 2)}\n`;
|
|
1432
|
-
const intent
|
|
1433
|
-
const action
|
|
1432
|
+
const intent = await evaluateWriteIntent(targetPath, buildWriteIntentOptions(data));
|
|
1433
|
+
const action = async () => {
|
|
1434
1434
|
await fs_extra.default.outputFile(targetPath, data, "utf8");
|
|
1435
1435
|
logger.success(targetPath);
|
|
1436
1436
|
};
|
|
1437
|
-
await scheduleOverwrite(intent
|
|
1437
|
+
await scheduleOverwrite(intent, {
|
|
1438
1438
|
relPath,
|
|
1439
1439
|
targetPath,
|
|
1440
|
-
action
|
|
1440
|
+
action,
|
|
1441
1441
|
pending: pendingOverwrites
|
|
1442
1442
|
});
|
|
1443
1443
|
continue;
|
|
@@ -1448,15 +1448,15 @@ async function upgradeMonorepo(opts) {
|
|
|
1448
1448
|
const targetManifest = exists ? normalizeWorkspaceManifest(yaml.default.parse(await fs_extra.default.readFile(targetPath, "utf8"))) : normalizeWorkspaceManifest({});
|
|
1449
1449
|
const mergedManifest = exists ? mergeWorkspaceManifest(sourceManifest, targetManifest) : sourceManifest;
|
|
1450
1450
|
const data = yaml.default.stringify(mergedManifest, { singleQuote: true });
|
|
1451
|
-
const intent
|
|
1452
|
-
const action
|
|
1451
|
+
const intent = await evaluateWriteIntent(targetPath, buildWriteIntentOptions(data));
|
|
1452
|
+
const action = async () => {
|
|
1453
1453
|
await fs_extra.default.outputFile(targetPath, data, "utf8");
|
|
1454
1454
|
logger.success(targetPath);
|
|
1455
1455
|
};
|
|
1456
|
-
await scheduleOverwrite(intent
|
|
1456
|
+
await scheduleOverwrite(intent, {
|
|
1457
1457
|
relPath,
|
|
1458
1458
|
targetPath,
|
|
1459
|
-
action
|
|
1459
|
+
action,
|
|
1460
1460
|
pending: pendingOverwrites
|
|
1461
1461
|
});
|
|
1462
1462
|
continue;
|
|
@@ -1465,48 +1465,48 @@ async function upgradeMonorepo(opts) {
|
|
|
1465
1465
|
const changesetJson = await fs_extra.default.readJson(file.path);
|
|
1466
1466
|
(0, import_set_value.default)(changesetJson, "changelog.1.repo", repoName);
|
|
1467
1467
|
const data = `${JSON.stringify(changesetJson, void 0, 2)}\n`;
|
|
1468
|
-
const intent
|
|
1469
|
-
const action
|
|
1468
|
+
const intent = await evaluateWriteIntent(targetPath, buildWriteIntentOptions(data));
|
|
1469
|
+
const action = async () => {
|
|
1470
1470
|
await fs_extra.default.outputFile(targetPath, data, "utf8");
|
|
1471
1471
|
logger.success(targetPath);
|
|
1472
1472
|
};
|
|
1473
|
-
await scheduleOverwrite(intent
|
|
1473
|
+
await scheduleOverwrite(intent, {
|
|
1474
1474
|
relPath,
|
|
1475
1475
|
targetPath,
|
|
1476
|
-
action
|
|
1476
|
+
action,
|
|
1477
1477
|
pending: pendingOverwrites
|
|
1478
1478
|
});
|
|
1479
1479
|
continue;
|
|
1480
1480
|
}
|
|
1481
1481
|
if (relPath === "LICENSE") {
|
|
1482
|
-
const source
|
|
1483
|
-
const intent
|
|
1482
|
+
const source = await fs_extra.default.readFile(file.path);
|
|
1483
|
+
const intent = await evaluateWriteIntent(targetPath, {
|
|
1484
1484
|
skipOverwrite: true,
|
|
1485
|
-
source
|
|
1485
|
+
source
|
|
1486
1486
|
});
|
|
1487
|
-
const action
|
|
1488
|
-
await fs_extra.default.outputFile(targetPath, source
|
|
1487
|
+
const action = async () => {
|
|
1488
|
+
await fs_extra.default.outputFile(targetPath, source);
|
|
1489
1489
|
logger.success(targetPath);
|
|
1490
1490
|
};
|
|
1491
|
-
await scheduleOverwrite(intent
|
|
1491
|
+
await scheduleOverwrite(intent, {
|
|
1492
1492
|
relPath,
|
|
1493
1493
|
targetPath,
|
|
1494
|
-
action
|
|
1494
|
+
action,
|
|
1495
1495
|
pending: pendingOverwrites
|
|
1496
1496
|
});
|
|
1497
1497
|
continue;
|
|
1498
1498
|
}
|
|
1499
1499
|
if (relPath === ".github/ISSUE_TEMPLATE/config.yml") {
|
|
1500
1500
|
const data = updateIssueTemplateConfig(await fs_extra.default.readFile(file.path, "utf8"), repoName);
|
|
1501
|
-
const intent
|
|
1502
|
-
const action
|
|
1501
|
+
const intent = await evaluateWriteIntent(targetPath, buildWriteIntentOptions(data));
|
|
1502
|
+
const action = async () => {
|
|
1503
1503
|
await fs_extra.default.outputFile(targetPath, data);
|
|
1504
1504
|
logger.success(targetPath);
|
|
1505
1505
|
};
|
|
1506
|
-
await scheduleOverwrite(intent
|
|
1506
|
+
await scheduleOverwrite(intent, {
|
|
1507
1507
|
relPath,
|
|
1508
1508
|
targetPath,
|
|
1509
|
-
action
|
|
1509
|
+
action,
|
|
1510
1510
|
pending: pendingOverwrites
|
|
1511
1511
|
});
|
|
1512
1512
|
continue;
|