@mongez/pkgist 1.0.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.
Files changed (49) hide show
  1. package/.prettierignore +4 -0
  2. package/.prettierrc +8 -0
  3. package/README.md +320 -0
  4. package/builder.ts +183 -0
  5. package/dist/cli.d.ts +1 -0
  6. package/dist/cli.js +1125 -0
  7. package/dist/cli.js.map +1 -0
  8. package/dist/index.d.ts +202 -0
  9. package/dist/index.js +824 -0
  10. package/dist/index.js.map +1 -0
  11. package/eslint.config.js +98 -0
  12. package/package.json +49 -0
  13. package/src/build/family-builder.ts +76 -0
  14. package/src/build/index.ts +4 -0
  15. package/src/build/package-builder.ts +155 -0
  16. package/src/build/parallel-builder.ts +36 -0
  17. package/src/cli.ts +51 -0
  18. package/src/commands/build-all.ts +88 -0
  19. package/src/commands/build-family.ts +55 -0
  20. package/src/commands/build.ts +84 -0
  21. package/src/commands/index.ts +5 -0
  22. package/src/commands/list.ts +74 -0
  23. package/src/commands/validate.ts +125 -0
  24. package/src/compile/index.ts +1 -0
  25. package/src/compile/tsdown-compiler.ts +344 -0
  26. package/src/config/define-config.ts +9 -0
  27. package/src/config/index.ts +3 -0
  28. package/src/config/load-config.ts +103 -0
  29. package/src/files/clone-files.ts +45 -0
  30. package/src/files/file-manager.ts +109 -0
  31. package/src/files/index.ts +3 -0
  32. package/src/files/package-json.ts +191 -0
  33. package/src/git/index.ts +1 -0
  34. package/src/git/operations.ts +87 -0
  35. package/src/index.ts +26 -0
  36. package/src/publish/index.ts +1 -0
  37. package/src/publish/npm-publisher.ts +36 -0
  38. package/src/types/config.ts +33 -0
  39. package/src/types/index.ts +2 -0
  40. package/src/types/package.ts +81 -0
  41. package/src/utils/errors.ts +40 -0
  42. package/src/utils/exec.ts +58 -0
  43. package/src/utils/index.ts +4 -0
  44. package/src/utils/logger.ts +44 -0
  45. package/src/utils/paths.ts +48 -0
  46. package/src/version/increment.ts +51 -0
  47. package/src/version/index.ts +1 -0
  48. package/tsconfig.json +20 -0
  49. package/tsup.config.ts +34 -0
@@ -0,0 +1,51 @@
1
+ import semver from "semver";
2
+ import { wrapError } from "../utils/errors.js";
3
+
4
+ /**
5
+ * Given the current version string and a version strategy, return the new version.
6
+ *
7
+ * @param currentVersion semver string from source package.json, e.g. "1.2.3"
8
+ * @param strategy "auto" / "patch" → patch bump
9
+ * "minor" → minor bump
10
+ * "major" → major bump
11
+ * any valid semver string → use as-is
12
+ * @param packageName used in error messages only
13
+ */
14
+ export function resolveVersion(
15
+ currentVersion: string,
16
+ strategy: "auto" | "patch" | "minor" | "major" | string = "auto",
17
+ packageName: string,
18
+ ): string {
19
+ const bumpType =
20
+ strategy === "auto" || strategy === "patch" ? "patch"
21
+ : strategy === "minor" ? "minor"
22
+ : strategy === "major" ? "major"
23
+ : null;
24
+
25
+ if (bumpType) {
26
+ const bumped = semver.inc(currentVersion, bumpType);
27
+ if (!bumped) {
28
+ throw wrapError(
29
+ "version-increment",
30
+ packageName,
31
+ new Error(
32
+ `Cannot ${bumpType}-bump invalid semver version "${currentVersion}" for package "${packageName}"`,
33
+ ),
34
+ );
35
+ }
36
+ return bumped;
37
+ }
38
+
39
+ // Explicit version string — validate it
40
+ const cleaned = semver.valid(semver.coerce(strategy) ?? strategy);
41
+ if (!cleaned) {
42
+ throw wrapError(
43
+ "version-increment",
44
+ packageName,
45
+ new Error(
46
+ `Explicit version "${strategy}" is not a valid semver string for package "${packageName}"`,
47
+ ),
48
+ );
49
+ }
50
+ return cleaned;
51
+ }
@@ -0,0 +1 @@
1
+ export { resolveVersion } from "./increment.js";
package/tsconfig.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "Bundler",
6
+ "lib": ["ES2022"],
7
+ "strict": true,
8
+ "esModuleInterop": true,
9
+ "skipLibCheck": true,
10
+ "resolveJsonModule": true,
11
+ "declaration": true,
12
+ "declarationMap": true,
13
+ "sourceMap": true,
14
+ "outDir": "./dist",
15
+ "rootDir": "./src",
16
+ "types": ["node"]
17
+ },
18
+ "include": ["src/**/*"],
19
+ "exclude": ["node_modules", "dist"]
20
+ }
package/tsup.config.ts ADDED
@@ -0,0 +1,34 @@
1
+ import { defineConfig } from "tsup";
2
+
3
+ export default defineConfig([
4
+ // Library entry
5
+ {
6
+ entry: { index: "src/index.ts" },
7
+ format: ["esm"],
8
+ dts: true,
9
+ sourcemap: true,
10
+ clean: true,
11
+ splitting: false,
12
+ shims: true,
13
+ target: "node18",
14
+ outDir: "dist",
15
+ esbuildOptions(options) {
16
+ options.platform = "node";
17
+ },
18
+ },
19
+ // CLI entry — the shebang comes from the first line of src/cli.ts
20
+ {
21
+ entry: { cli: "src/cli.ts" },
22
+ format: ["esm"],
23
+ dts: true,
24
+ sourcemap: true,
25
+ clean: false,
26
+ splitting: false,
27
+ shims: true,
28
+ target: "node18",
29
+ outDir: "dist",
30
+ esbuildOptions(options) {
31
+ options.platform = "node";
32
+ },
33
+ },
34
+ ]);