monocrate 0.4.0 → 0.6.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/README.md +72 -149
- package/dist/collect-package-locations.d.ts +7 -43
- package/dist/collect-package-locations.d.ts.map +1 -1
- package/dist/collect-package-locations.js +23 -19
- package/dist/collect-package-locations.js.map +1 -1
- package/dist/compute-package-closure.d.ts +2 -1
- package/dist/compute-package-closure.d.ts.map +1 -1
- package/dist/compute-package-closure.js +37 -12
- package/dist/compute-package-closure.js.map +1 -1
- package/dist/file-copier.d.ts +4 -4
- package/dist/file-copier.d.ts.map +1 -1
- package/dist/file-copier.js +5 -6
- package/dist/file-copier.js.map +1 -1
- package/dist/get-files-to-pack.d.ts +3 -1
- package/dist/get-files-to-pack.d.ts.map +1 -1
- package/dist/get-files-to-pack.js +7 -33
- package/dist/get-files-to-pack.js.map +1 -1
- package/dist/import-rewriter.d.ts +4 -4
- package/dist/import-rewriter.d.ts.map +1 -1
- package/dist/import-rewriter.js +5 -7
- package/dist/import-rewriter.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mirror-sources.d.ts +11 -0
- package/dist/mirror-sources.d.ts.map +1 -0
- package/dist/mirror-sources.js +90 -0
- package/dist/mirror-sources.js.map +1 -0
- package/dist/monocrate-cli.d.ts.map +1 -1
- package/dist/monocrate-cli.js +74 -38
- package/dist/monocrate-cli.js.map +1 -1
- package/dist/monocrate-options.d.ts +67 -0
- package/dist/monocrate-options.d.ts.map +1 -0
- package/dist/monocrate-options.js +2 -0
- package/dist/monocrate-options.js.map +1 -0
- package/dist/monocrate-result.d.ts +18 -0
- package/dist/monocrate-result.d.ts.map +1 -0
- package/dist/monocrate-result.js +2 -0
- package/dist/monocrate-result.js.map +1 -0
- package/dist/monocrate.d.ts +6 -32
- package/dist/monocrate.d.ts.map +1 -1
- package/dist/monocrate.js +64 -18
- package/dist/monocrate.js.map +1 -1
- package/dist/name-mangler.d.ts +2 -0
- package/dist/name-mangler.d.ts.map +1 -0
- package/dist/name-mangler.js +4 -0
- package/dist/name-mangler.js.map +1 -0
- package/dist/npm-client.d.ts +29 -0
- package/dist/npm-client.d.ts.map +1 -0
- package/dist/npm-client.js +83 -0
- package/dist/npm-client.js.map +1 -0
- package/dist/package-assembler.d.ts +16 -0
- package/dist/package-assembler.d.ts.map +1 -0
- package/dist/package-assembler.js +52 -0
- package/dist/package-assembler.js.map +1 -0
- package/dist/package-closure.d.ts +1 -1
- package/dist/package-closure.d.ts.map +1 -1
- package/dist/{package-map.d.ts → package-location.d.ts} +9 -10
- package/dist/package-location.d.ts.map +1 -0
- package/dist/package-location.js +2 -0
- package/dist/package-location.js.map +1 -0
- package/dist/paths.d.ts +37 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +59 -0
- package/dist/paths.js.map +1 -0
- package/dist/publish.d.ts +3 -1
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js +2 -6
- package/dist/publish.js.map +1 -1
- package/dist/repo-explorer.d.ts +23 -0
- package/dist/repo-explorer.d.ts.map +1 -0
- package/dist/repo-explorer.js +121 -0
- package/dist/repo-explorer.js.map +1 -0
- package/dist/resolve-version.d.ts +4 -1
- package/dist/resolve-version.d.ts.map +1 -1
- package/dist/resolve-version.js +31 -33
- package/dist/resolve-version.js.map +1 -1
- package/dist/rewrite-package-json.d.ts +2 -1
- package/dist/rewrite-package-json.d.ts.map +1 -1
- package/dist/rewrite-package-json.js.map +1 -1
- package/dist/run-npm.d.ts +36 -0
- package/dist/run-npm.d.ts.map +1 -0
- package/dist/run-npm.js +35 -0
- package/dist/run-npm.js.map +1 -0
- package/package.json +10 -3
- package/dist/assemble.d.ts +0 -4
- package/dist/assemble.d.ts.map +0 -1
- package/dist/assemble.js +0 -21
- package/dist/assemble.js.map +0 -1
- package/dist/monorepo.d.ts +0 -9
- package/dist/monorepo.d.ts.map +0 -1
- package/dist/monorepo.js +0 -82
- package/dist/monorepo.js.map +0 -1
- package/dist/package-map.d.ts.map +0 -1
- package/dist/package-map.js +0 -2
- package/dist/package-map.js.map +0 -1
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
import { exec } from 'node:child_process';
|
|
2
|
-
import { promisify } from 'node:util';
|
|
3
|
-
import { z } from 'zod';
|
|
4
|
-
const execAsync = promisify(exec);
|
|
5
|
-
const NpmPackFile = z.object({
|
|
6
|
-
path: z.string(),
|
|
7
|
-
});
|
|
8
|
-
const NpmPackResult = z.object({
|
|
9
|
-
files: z.array(NpmPackFile),
|
|
10
|
-
});
|
|
11
|
-
const NpmPackOutput = z.array(NpmPackResult);
|
|
12
|
-
const NpmPackError = z.object({
|
|
13
|
-
error: z.object({
|
|
14
|
-
summary: z.string(),
|
|
15
|
-
}),
|
|
16
|
-
});
|
|
17
1
|
/**
|
|
18
2
|
* Gets the list of files that npm would include in a package tarball.
|
|
19
3
|
* Uses `npm pack --dry-run --json` to get npm's exact file selection.
|
|
@@ -22,25 +6,15 @@ const NpmPackError = z.object({
|
|
|
22
6
|
* @returns Array of relative file paths that npm would include
|
|
23
7
|
* @example getFilesToPack("/home/user/my-package") => ["dist/index.js", "README.md", "package.json"]
|
|
24
8
|
*/
|
|
25
|
-
export async function getFilesToPack(packageDir) {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
});
|
|
30
|
-
const json = JSON.parse(stdout);
|
|
31
|
-
// Check if npm returned an error
|
|
32
|
-
const errorResult = NpmPackError.safeParse(json);
|
|
33
|
-
if (errorResult.success) {
|
|
34
|
-
throw new Error(`npm pack failed: ${errorResult.data.error.summary}`);
|
|
9
|
+
export async function getFilesToPack(npmClient, packageDir) {
|
|
10
|
+
const o = await npmClient.pack(packageDir, { dryRun: true });
|
|
11
|
+
if (o.length !== 1) {
|
|
12
|
+
throw new Error(`Expected npm pack to return a single element array`);
|
|
35
13
|
}
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
38
|
-
throw new Error(`Failed to parse npm pack output: ${parsed.error.message}`);
|
|
39
|
-
}
|
|
40
|
-
const packOutput = parsed.data[0];
|
|
41
|
-
if (packOutput === undefined) {
|
|
14
|
+
const at0 = o.at(0);
|
|
15
|
+
if (at0 === undefined) {
|
|
42
16
|
throw new Error('npm pack returned empty output');
|
|
43
17
|
}
|
|
44
|
-
return
|
|
18
|
+
return at0.files.map((f) => f.path);
|
|
45
19
|
}
|
|
46
20
|
//# sourceMappingURL=get-files-to-pack.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-files-to-pack.js","sourceRoot":"","sources":["../src/get-files-to-pack.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-files-to-pack.js","sourceRoot":"","sources":["../src/get-files-to-pack.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,SAAoB,EAAE,UAAwB;IACjF,MAAM,CAAC,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;IAC5D,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAA;IACvE,CAAC;IAED,MAAM,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IACnB,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;IACnD,CAAC;IAED,OAAO,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;AACrC,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { PackageMap } from './package-
|
|
1
|
+
import type { PackageMap } from './package-location.js';
|
|
2
|
+
import { AbsolutePath } from './paths.js';
|
|
2
3
|
export declare class ImportRewriter {
|
|
3
4
|
private packageMap;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
rewriteAll(files: string[]): Promise<void>;
|
|
5
|
+
constructor(packageMap: PackageMap);
|
|
6
|
+
rewriteAll(files: AbsolutePath[]): Promise<void>;
|
|
7
7
|
private rewriteFile;
|
|
8
8
|
private computeNewSpecifier;
|
|
9
9
|
private extractPackageName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-rewriter.d.ts","sourceRoot":"","sources":["../src/import-rewriter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"import-rewriter.d.ts","sourceRoot":"","sources":["../src/import-rewriter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAEvD,OAAO,EAAE,YAAY,EAAgB,MAAM,YAAY,CAAA;AAEvD,qBAAa,cAAc;IACb,OAAO,CAAC,UAAU;gBAAV,UAAU,EAAE,UAAU;IAEpC,UAAU,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;YAOxC,WAAW;IAqDzB,OAAO,CAAC,mBAAmB;IAc3B,OAAO,CAAC,kBAAkB;IAM1B,OAAO,CAAC,mBAAmB;CAO5B"}
|
package/dist/import-rewriter.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import * as path from 'node:path';
|
|
2
2
|
import { Project, SyntaxKind } from 'ts-morph';
|
|
3
3
|
import { resolveImport } from './collect-package-locations.js';
|
|
4
|
+
import { AbsolutePath, RelativePath } from './paths.js';
|
|
4
5
|
export class ImportRewriter {
|
|
5
6
|
packageMap;
|
|
6
|
-
|
|
7
|
-
constructor(packageMap, outputDir) {
|
|
7
|
+
constructor(packageMap) {
|
|
8
8
|
this.packageMap = packageMap;
|
|
9
|
-
this.outputDir = outputDir;
|
|
10
9
|
}
|
|
11
10
|
async rewriteAll(files) {
|
|
12
11
|
const jsAndDtsFiles = files.filter((f) => f.endsWith('.js') || f.endsWith('.d.ts'));
|
|
@@ -67,16 +66,15 @@ export class ImportRewriter {
|
|
|
67
66
|
if (!importeeLocation) {
|
|
68
67
|
return undefined;
|
|
69
68
|
}
|
|
70
|
-
const pathAtImportee = resolveImport(importeeLocation, subPath);
|
|
71
|
-
return this.computeRelativePath(pathToImporter, pathAtImportee);
|
|
69
|
+
const pathAtImportee = resolveImport(importeeLocation.packageJson, subPath);
|
|
70
|
+
return this.computeRelativePath(pathToImporter, AbsolutePath.join(importeeLocation.toDir, RelativePath(pathAtImportee)));
|
|
72
71
|
}
|
|
73
72
|
extractPackageName(specifier) {
|
|
74
73
|
const parts = specifier.split('/');
|
|
75
74
|
const cutoff = specifier.startsWith('@') ? 2 : 1;
|
|
76
75
|
return { packageName: parts.slice(0, cutoff).join('/'), subPath: parts.slice(cutoff).join('/') };
|
|
77
76
|
}
|
|
78
|
-
computeRelativePath(importerPath,
|
|
79
|
-
const absoluteImporteePath = path.join(this.outputDir, importeePath);
|
|
77
|
+
computeRelativePath(importerPath, absoluteImporteePath) {
|
|
80
78
|
let relative = path.relative(path.dirname(importerPath), absoluteImporteePath);
|
|
81
79
|
if (!relative.startsWith('.')) {
|
|
82
80
|
relative = './' + relative;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-rewriter.js","sourceRoot":"","sources":["../src/import-rewriter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAA;
|
|
1
|
+
{"version":3,"file":"import-rewriter.js","sourceRoot":"","sources":["../src/import-rewriter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,UAAU,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;QAC5B,CAAC;QACD,OAAO,QAAQ,CAAA;IACjB,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { monocrate, type MonocrateOptions } from './monocrate.js';
|
|
1
|
+
export { monocrate, type MonocrateOptions, type MonocrateResult } from './monocrate.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAA"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA+C,MAAM,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { MonorepoPackage } from './repo-explorer.js';
|
|
2
|
+
import { AbsolutePath } from './paths.js';
|
|
3
|
+
/**
|
|
4
|
+
* Mirrors source code of packages to a target directory.
|
|
5
|
+
* Each package's files are copied preserving the path structure relative to the monorepo root.
|
|
6
|
+
* Only committed files (from HEAD) are copied.
|
|
7
|
+
* Throws if any package has untracked files.
|
|
8
|
+
* Each package's target directory is wiped before copying.
|
|
9
|
+
*/
|
|
10
|
+
export declare function mirrorSources(packages: MonorepoPackage[], mirrorDir: AbsolutePath): Promise<void>;
|
|
11
|
+
//# sourceMappingURL=mirror-sources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mirror-sources.d.ts","sourceRoot":"","sources":["../src/mirror-sources.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,EAAE,YAAY,EAAgB,MAAM,YAAY,CAAA;AA2EvD;;;;;;GAMG;AACH,wBAAsB,aAAa,CAAC,QAAQ,EAAE,eAAe,EAAE,EAAE,SAAS,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAyBvG"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { execSync } from 'node:child_process';
|
|
2
|
+
import * as fs from 'node:fs';
|
|
3
|
+
import * as fsPromises from 'node:fs/promises';
|
|
4
|
+
import * as path from 'node:path';
|
|
5
|
+
import { AbsolutePath, RelativePath } from './paths.js';
|
|
6
|
+
/**
|
|
7
|
+
* Lists files in a directory that are committed in git (not just staged).
|
|
8
|
+
* Uses `git ls-tree` to get only files from HEAD.
|
|
9
|
+
* Throws if there are any untracked files.
|
|
10
|
+
*/
|
|
11
|
+
function listCommittedFiles(packageDir) {
|
|
12
|
+
// Check for untracked files (not gitignored)
|
|
13
|
+
const untrackedOutput = execSync('git ls-files --others --exclude-standard', {
|
|
14
|
+
cwd: packageDir,
|
|
15
|
+
encoding: 'utf-8',
|
|
16
|
+
});
|
|
17
|
+
const untrackedFiles = untrackedOutput
|
|
18
|
+
.split('\n')
|
|
19
|
+
.map((line) => line.trim())
|
|
20
|
+
.filter((line) => line.length > 0);
|
|
21
|
+
if (untrackedFiles.length > 0) {
|
|
22
|
+
throw new Error(`Cannot mirror: found ${String(untrackedFiles.length)} untracked file(s) in ${packageDir}. ` +
|
|
23
|
+
`First few: ${untrackedFiles.slice(0, 3).join(', ')}. ` +
|
|
24
|
+
`Commit or gitignore them before mirroring.`);
|
|
25
|
+
}
|
|
26
|
+
// Get only committed files from HEAD
|
|
27
|
+
// -r: recursive
|
|
28
|
+
// --name-only: show only file names
|
|
29
|
+
const output = execSync('git ls-tree -r --name-only HEAD', {
|
|
30
|
+
cwd: packageDir,
|
|
31
|
+
encoding: 'utf-8',
|
|
32
|
+
});
|
|
33
|
+
return output
|
|
34
|
+
.split('\n')
|
|
35
|
+
.map((line) => line.trim())
|
|
36
|
+
.filter((line) => line.length > 0)
|
|
37
|
+
.map((line) => RelativePath(line));
|
|
38
|
+
}
|
|
39
|
+
function collectCopyOperations(packages, mirrorDir) {
|
|
40
|
+
const operations = [];
|
|
41
|
+
for (const pkg of packages) {
|
|
42
|
+
const targetDir = AbsolutePath.join(mirrorDir, pkg.pathInRepo);
|
|
43
|
+
const files = listCommittedFiles(pkg.fromDir);
|
|
44
|
+
for (const relativePath of files) {
|
|
45
|
+
const sourceFile = AbsolutePath.join(pkg.fromDir, relativePath);
|
|
46
|
+
if (!fs.existsSync(sourceFile)) {
|
|
47
|
+
throw new Error(`Source file does not exist: ${sourceFile}`);
|
|
48
|
+
}
|
|
49
|
+
const stat = fs.statSync(sourceFile);
|
|
50
|
+
if (stat.isDirectory()) {
|
|
51
|
+
throw new Error(`git ls-files returned a directory, which is unexpected: ${sourceFile}`);
|
|
52
|
+
}
|
|
53
|
+
operations.push({
|
|
54
|
+
source: sourceFile,
|
|
55
|
+
destination: AbsolutePath.join(targetDir, relativePath),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return operations;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Mirrors source code of packages to a target directory.
|
|
63
|
+
* Each package's files are copied preserving the path structure relative to the monorepo root.
|
|
64
|
+
* Only committed files (from HEAD) are copied.
|
|
65
|
+
* Throws if any package has untracked files.
|
|
66
|
+
* Each package's target directory is wiped before copying.
|
|
67
|
+
*/
|
|
68
|
+
export async function mirrorSources(packages, mirrorDir) {
|
|
69
|
+
// TODO(imaman): can we dedup with file-copier.ts?
|
|
70
|
+
// Phase 1: Wipe target directories for each package
|
|
71
|
+
for (const pkg of packages) {
|
|
72
|
+
const targetDir = AbsolutePath.join(mirrorDir, pkg.pathInRepo);
|
|
73
|
+
if (fs.existsSync(targetDir)) {
|
|
74
|
+
await fsPromises.rm(targetDir, { recursive: true });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// Phase 2: Collect all copy operations
|
|
78
|
+
const operations = collectCopyOperations(packages, mirrorDir);
|
|
79
|
+
// Phase 3: Create all unique directories
|
|
80
|
+
const directories = new Set(operations.map((op) => path.dirname(op.destination)));
|
|
81
|
+
for (const dir of directories) {
|
|
82
|
+
await fsPromises.mkdir(dir, { recursive: true });
|
|
83
|
+
}
|
|
84
|
+
// TODO(imaman): make the loop run concurrently (with some controlled concurrency).
|
|
85
|
+
// Phase 4: Copy all files
|
|
86
|
+
for (const op of operations) {
|
|
87
|
+
await fsPromises.copyFile(op.source, op.destination);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=mirror-sources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mirror-sources.js","sourceRoot":"","sources":["../src/mirror-sources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAA;AAC9C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAEjC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAOvD;;;;GAIG;AACH,SAAS,kBAAkB,CAAC,UAAwB;IAClD,6CAA6C;IAC7C,MAAM,eAAe,GAAG,QAAQ,CAAC,0CAA0C,EAAE;QAC3E,GAAG,EAAE,UAAU;QACf,QAAQ,EAAE,OAAO;KAClB,CAAC,CAAA;IACF,MAAM,cAAc,GAAG,eAAe;SACnC,KAAK,CAAC,IAAI,CA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AC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAAA;IACjF,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QAC9B,MAAM,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAClD,CAAC;IAED,mFAAmF;IACnF,0BAA0B;IAC1B,KAAK,MAAM,EAAE,IAAI,UAAU,EAAE,CAAC;QAC5B,MAAM,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,WAAW,CAAC,CAAA;IACtD,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monocrate-cli.d.ts","sourceRoot":"","sources":["../src/monocrate-cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"monocrate-cli.d.ts","sourceRoot":"","sources":["../src/monocrate-cli.ts"],"names":[],"mappings":"AA+DA,wBAAgB,YAAY,IAAI,IAAI,CAgDnC"}
|
package/dist/monocrate-cli.js
CHANGED
|
@@ -1,46 +1,82 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import yargs from 'yargs';
|
|
3
|
+
import { hideBin } from 'yargs/helpers';
|
|
2
4
|
import { monocrate } from './monocrate.js';
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const require = createRequire(import.meta.url);
|
|
6
|
+
const pkg = require('../package.json');
|
|
7
|
+
const sharedOptions = {
|
|
8
|
+
bump: {
|
|
9
|
+
alias: 'b',
|
|
10
|
+
type: 'string',
|
|
11
|
+
description: 'Version or increment (patch/minor/major)',
|
|
7
12
|
},
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
required: true,
|
|
13
|
-
},
|
|
14
|
-
output: {
|
|
15
|
-
type: 'positional',
|
|
16
|
-
description: 'Output directory (creates a dedicated temp directory if not specified)',
|
|
17
|
-
required: false,
|
|
18
|
-
},
|
|
19
|
-
root: {
|
|
20
|
-
type: 'string',
|
|
21
|
-
description: 'Monorepo root directory (auto-detected if not specified)',
|
|
22
|
-
alias: 'r',
|
|
23
|
-
},
|
|
24
|
-
publish: {
|
|
25
|
-
type: 'string',
|
|
26
|
-
description: 'Publish to npm with version: x.y.z (explicit) or patch|minor|major (increment)',
|
|
27
|
-
alias: 'p',
|
|
28
|
-
},
|
|
13
|
+
output: {
|
|
14
|
+
alias: 'o',
|
|
15
|
+
type: 'string',
|
|
16
|
+
description: 'Output directory',
|
|
29
17
|
},
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
...(outputDir ? { outputDir } : {}),
|
|
35
|
-
monorepoRoot: args.root,
|
|
36
|
-
publishToVersion: args.publish,
|
|
37
|
-
cwd: process.cwd(),
|
|
38
|
-
});
|
|
39
|
-
console.log(actualOutputDir);
|
|
18
|
+
root: {
|
|
19
|
+
alias: 'r',
|
|
20
|
+
type: 'string',
|
|
21
|
+
description: 'Monorepo root (auto-detected if omitted)',
|
|
40
22
|
},
|
|
41
|
-
|
|
23
|
+
report: {
|
|
24
|
+
type: 'string',
|
|
25
|
+
description: 'Write report to file',
|
|
26
|
+
},
|
|
27
|
+
'mirror-to': {
|
|
28
|
+
alias: 'm',
|
|
29
|
+
type: 'string',
|
|
30
|
+
description: 'Mirror source files to directory',
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
async function runCommand(argv, publish) {
|
|
34
|
+
const packages = argv.packages ?? [];
|
|
35
|
+
if (packages.length === 0) {
|
|
36
|
+
throw new Error('At least one package directory must be specified');
|
|
37
|
+
}
|
|
38
|
+
const options = {
|
|
39
|
+
pathToSubjectPackages: packages,
|
|
40
|
+
outputRoot: argv.output,
|
|
41
|
+
monorepoRoot: argv.root,
|
|
42
|
+
bump: argv.bump,
|
|
43
|
+
publish,
|
|
44
|
+
report: argv.report,
|
|
45
|
+
cwd: process.cwd(),
|
|
46
|
+
mirrorTo: argv['mirror-to'],
|
|
47
|
+
};
|
|
48
|
+
await monocrate(options);
|
|
49
|
+
}
|
|
42
50
|
export function monocrateCli() {
|
|
43
|
-
|
|
51
|
+
const parser = yargs(hideBin(process.argv))
|
|
52
|
+
.scriptName('monocrate')
|
|
53
|
+
.version(pkg.version)
|
|
54
|
+
.usage(`From monorepo to npm in one command.
|
|
55
|
+
|
|
56
|
+
Point at your packages. That's it.`)
|
|
57
|
+
.example('$0 publish pkg/foo --bump patch', 'Bump to next patch and publish')
|
|
58
|
+
.example('$0 publish libs/a libs/b', 'Multi-package (defaults to minor bump)')
|
|
59
|
+
.command('publish <packages...>', 'Publish to npm', (yargs) => yargs.options(sharedOptions).positional('packages', {
|
|
60
|
+
describe: 'Package directories to publish',
|
|
61
|
+
type: 'string',
|
|
62
|
+
array: true,
|
|
63
|
+
}), async (argv) => {
|
|
64
|
+
await runCommand(argv, true);
|
|
65
|
+
})
|
|
66
|
+
.command('prepare <packages...>', 'Same as publish, but stop short of publishing', (yargs) => yargs.options(sharedOptions).positional('packages', {
|
|
67
|
+
describe: 'Package directories to prepare',
|
|
68
|
+
type: 'string',
|
|
69
|
+
array: true,
|
|
70
|
+
}), async (argv) => {
|
|
71
|
+
await runCommand(argv, false);
|
|
72
|
+
})
|
|
73
|
+
.demandCommand(1, 'Try: monocrate publish <package-dir>')
|
|
74
|
+
.strict()
|
|
75
|
+
.help()
|
|
76
|
+
.version(pkg.version)
|
|
77
|
+
.option('help', { hidden: true })
|
|
78
|
+
.option('version', { hidden: true });
|
|
79
|
+
void Promise.resolve(parser.parse()).catch((error) => {
|
|
44
80
|
console.error('Fatal error:', error instanceof Error ? error.stack : error);
|
|
45
81
|
process.exit(1);
|
|
46
82
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monocrate-cli.js","sourceRoot":"","sources":["../src/monocrate-cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"monocrate-cli.js","sourceRoot":"","sources":["../src/monocrate-cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC9C,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAwB,CAAA;AAE7D,MAAM,aAAa,GAAG;IACpB,IAAI,EAAE;QACJ,KAAK,EAAE,GAAG;QACV,IAAI,EAAE,QAAiB;QACvB,WAAW,EAAE,0CAA0C;KACxD;IACD,MAAM,EAAE;QACN,KAAK,EAAE,GAAG;QACV,IAAI,EAAE,QAAiB;QACvB,WAAW,EAAE,kBAAkB;KAChC;IACD,IAAI,EAAE;QACJ,KAAK,EAAE,GAAG;QACV,IAAI,EAAE,QAAiB;QACvB,WAAW,EAAE,0CAA0C;KACxD;IACD,MAAM,EAAE;QACN,IAAI,EAAE,QAAiB;QACvB,WAAW,EAAE,sBAAsB;KACpC;IACD,WAAW,EAAE;QACX,KAAK,EAAE,GAAG;QACV,IAAI,EAAE,QAAiB;QACvB,WAAW,EAAE,kCAAkC;KAChD;CACF,CAAA;AAWD,KAAK,UAAU,UAAU,CAAC,IAAe,EAAE,OAAgB;IACzD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAA;IACpC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAA;IACrE,CAAC;IACD,MAAM,OAAO,GAAqB;QACh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,EAAE;QACb,MAAM,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;IAC/B,CAAC,CACF;SACA,aAAa,CAAC,CAAC,EAAE,sCAAsC,CAAC;SACxD,MAAM,EAAE;SACR,IAAI,EAAE;SACN,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;SACpB,MAAM,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;SAChC,MAAM,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;IAEtC,KAAK,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;QAC5D,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;QAC3E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export interface MonocrateOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Paths to the directories of the various package to assemble. If a string, it is transformed to a single element array.
|
|
4
|
+
* Can be absolute or relative. Relative paths are resolved from the cwd option.
|
|
5
|
+
*/
|
|
6
|
+
pathToSubjectPackages: string[] | string;
|
|
7
|
+
/**
|
|
8
|
+
* Path to the output root directory where the assembly will be written.
|
|
9
|
+
* The actual output will be placed in a subdirectory named after the package.
|
|
10
|
+
* Can be absolute or relative. Relative paths are resolved from the cwd option.
|
|
11
|
+
* If not specified, a dedicated temp directory is created under the system temp directory.
|
|
12
|
+
*/
|
|
13
|
+
outputRoot?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Path to the monorepo root directory.
|
|
16
|
+
* Can be absolute or relative. Relative paths are resolved from the cwd option.
|
|
17
|
+
* If not specified, auto-detected by searching for a root package.json with workspaces.
|
|
18
|
+
*/
|
|
19
|
+
monorepoRoot?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Version specifier for the assembly.
|
|
22
|
+
* Accepts either an explicit semver version (e.g., "1.2.3") or an increment keyword ("patch", "minor", "major").
|
|
23
|
+
* The resolved version is either this value (if it is an explicit semver value) or is obtained by finding the
|
|
24
|
+
* current version of all the packages to publish, finding the highest version of these, and then applying
|
|
25
|
+
* the increment depicted by this value.
|
|
26
|
+
*
|
|
27
|
+
* Defaults to "minor".
|
|
28
|
+
*/
|
|
29
|
+
bump?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Whether to publish the assemblies to npm after building.
|
|
32
|
+
* When false, the assembly is prepared with the resolved version but not published
|
|
33
|
+
* (useful for inspection or manual publishing).
|
|
34
|
+
*/
|
|
35
|
+
publish: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Path to write the report (resolved version) to a file instead of stdout.
|
|
38
|
+
* Can be absolute or relative. Relative paths are resolved from the cwd option.
|
|
39
|
+
* If not specified, output is written to stdout.
|
|
40
|
+
*/
|
|
41
|
+
report?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Base directory for resolving relative paths. Must be a valid, existing directory.
|
|
44
|
+
*/
|
|
45
|
+
cwd: string;
|
|
46
|
+
/**
|
|
47
|
+
* Path to an .npmrc file to use in npm commands as "userconfig". Settings from this file are merged with any
|
|
48
|
+
* package-specific .npmrc file, with the package-specific file's settings winning on conflicts (see
|
|
49
|
+
* https://docs.npmjs.com/cli/v11/configuring-npm/npmrc#files).
|
|
50
|
+
*/
|
|
51
|
+
npmrcPath?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Path to a directory where source files should be mirrored.
|
|
54
|
+
*
|
|
55
|
+
* Primary use case: copying exact source code from a private monorepo to a public mirror
|
|
56
|
+
* repository for published, open-sourced, packages.
|
|
57
|
+
*
|
|
58
|
+
* Mirrors all assembled packages (the main package and its in-repo dependencies).
|
|
59
|
+
* Only committed files (from HEAD) are copied, preserving their path structure relative
|
|
60
|
+
* to the monorepo root. Fails if any package has untracked files.
|
|
61
|
+
* Each package's target directory is wiped before copying.
|
|
62
|
+
*
|
|
63
|
+
* Can be absolute or relative. Relative paths are resolved from the cwd option.
|
|
64
|
+
*/
|
|
65
|
+
mirrorTo?: string;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=monocrate-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monocrate-options.d.ts","sourceRoot":"","sources":["../src/monocrate-options.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,qBAAqB,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;IACxC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;;;;;OAQG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;;OAIG;IACH,OAAO,EAAE,OAAO,CAAA;IAChB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IAEX;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monocrate-options.js","sourceRoot":"","sources":["../src/monocrate-options.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface MonocrateResult {
|
|
2
|
+
/**
|
|
3
|
+
* The output directory path where the assembly of the first package was created.
|
|
4
|
+
*/
|
|
5
|
+
outputDir: string;
|
|
6
|
+
/**
|
|
7
|
+
* The new version (AKA: 'resolved version') for the package (or packages).
|
|
8
|
+
*/
|
|
9
|
+
resolvedVersion: string;
|
|
10
|
+
/**
|
|
11
|
+
* Details about each individual package that was assembled/published.
|
|
12
|
+
*/
|
|
13
|
+
summaries: {
|
|
14
|
+
packageName: string;
|
|
15
|
+
outputDir: string;
|
|
16
|
+
}[];
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=monocrate-result.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monocrate-result.d.ts","sourceRoot":"","sources":["../src/monocrate-result.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,eAAe,EAAE,MAAM,CAAA;IACvB;;OAEG;IACH,SAAS,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CACxD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monocrate-result.js","sourceRoot":"","sources":["../src/monocrate-result.ts"],"names":[],"mappings":""}
|
package/dist/monocrate.d.ts
CHANGED
|
@@ -1,38 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*/
|
|
6
|
-
pathToSubjectPackage: string;
|
|
7
|
-
/**
|
|
8
|
-
* Path to the output directory where the assembly will be written.
|
|
9
|
-
* Can be absolute or relative. Relative paths are resolved from the cwd option.
|
|
10
|
-
* If not specified, a dedicated temp directory is created under the system temp directory.
|
|
11
|
-
*/
|
|
12
|
-
outputDir?: string;
|
|
13
|
-
/**
|
|
14
|
-
* Path to the monorepo root directory.
|
|
15
|
-
* Can be absolute or relative. Relative paths are resolved from the cwd option.
|
|
16
|
-
* If not specified, auto-detected by searching for a root package.json with workspaces.
|
|
17
|
-
*/
|
|
18
|
-
monorepoRoot?: string;
|
|
19
|
-
/**
|
|
20
|
-
* Publish the assembly to npm after building.
|
|
21
|
-
* Accepts either an explicit semver version (e.g., "1.2.3") or an increment keyword ("patch", "minor", "major").
|
|
22
|
-
* When specified, the assembly is published to npm with the resolved version.
|
|
23
|
-
* If not specified, no publishing occurs.
|
|
24
|
-
*/
|
|
25
|
-
publishToVersion?: string;
|
|
26
|
-
/**
|
|
27
|
-
* Base directory for resolving relative paths. Must be a valid, existing directory.
|
|
28
|
-
*/
|
|
29
|
-
cwd: string;
|
|
30
|
-
}
|
|
1
|
+
import type { MonocrateResult } from './monocrate-result.js';
|
|
2
|
+
import type { MonocrateOptions } from './monocrate-options.js';
|
|
3
|
+
export type { MonocrateOptions } from './monocrate-options.js';
|
|
4
|
+
export type { MonocrateResult } from './monocrate-result.js';
|
|
31
5
|
/**
|
|
32
6
|
* Assembles a monorepo package and its in-repo dependencies for npm publishing.
|
|
33
7
|
* @param options - Configuration options for the assembly process
|
|
34
|
-
* @returns The
|
|
8
|
+
* @returns The result of the assembly operation
|
|
35
9
|
* @throws Error if assembly or publishing fails
|
|
36
10
|
*/
|
|
37
|
-
export declare function monocrate(options: MonocrateOptions): Promise<
|
|
11
|
+
export declare function monocrate(options: MonocrateOptions): Promise<MonocrateResult>;
|
|
38
12
|
//# sourceMappingURL=monocrate.d.ts.map
|
package/dist/monocrate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monocrate.d.ts","sourceRoot":"","sources":["../src/monocrate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"monocrate.d.ts","sourceRoot":"","sources":["../src/monocrate.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAE9D,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAC9D,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAE5D;;;;;GAKG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC,CAgFnF"}
|