@travetto/repo 7.1.3 → 7.1.4
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
CHANGED
|
@@ -13,14 +13,14 @@ npm install @travetto/repo
|
|
|
13
13
|
yarn add @travetto/repo
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
The repo module aims to provide concise monorepo based tools. The monorepo support within the [Travetto](https://travetto.dev) framework, is
|
|
16
|
+
The repo module aims to provide concise monorepo based tools. The monorepo support within the [Travetto](https://travetto.dev) framework, is backed by the built in functionality of [Npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)/[Yarn](https://yarnpkg.com). This module is not a requirement for monorepo support, but provides some quality of life improvements for:
|
|
17
17
|
* Versioning releases
|
|
18
18
|
* Publishing releases
|
|
19
19
|
* Listing local modules
|
|
20
20
|
* Running commands on all workspace modules
|
|
21
21
|
|
|
22
22
|
## CLI - Version
|
|
23
|
-
The versioning operation will find all the changed modules (and the modules that depend on the changed), and will update the versions in accordance with the user preferences. The versioning logic is backed by [Npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)
|
|
23
|
+
The versioning operation will find all the changed modules (and the modules that depend on the changed), and will update the versions in accordance with the user preferences. The versioning logic is backed by [Npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)/[Yarn](https://yarnpkg.com)'s versioning functionality and so it is identical to using the tool manually. The determination of what has or hasn't changed is relative to the last versioning commit.
|
|
24
24
|
|
|
25
25
|
**Terminal: Version execution**
|
|
26
26
|
```bash
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/repo",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Monorepo utilities",
|
|
6
6
|
"keywords": [
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
"directory": "module/repo"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@travetto/worker": "^7.1.
|
|
26
|
+
"@travetto/worker": "^7.1.4"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@travetto/cli": "^7.1.
|
|
29
|
+
"@travetto/cli": "^7.1.4"
|
|
30
30
|
},
|
|
31
31
|
"peerDependenciesMeta": {
|
|
32
32
|
"@travetto/cli": {
|
|
@@ -2,14 +2,12 @@ import path from 'node:path';
|
|
|
2
2
|
import { spawn, type ChildProcess } from 'node:child_process';
|
|
3
3
|
import fs from 'node:fs/promises';
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import { type IndexedModule, type
|
|
5
|
+
import { type ExecutionResult, JSONUtil, Runtime } from '@travetto/runtime';
|
|
6
|
+
import { type IndexedModule, type Package, PackageUtil } from '@travetto/manifest';
|
|
7
7
|
import { CliModuleUtil } from '@travetto/cli';
|
|
8
8
|
|
|
9
9
|
export type SemverLevel = 'minor' | 'patch' | 'major' | 'prerelease' | 'premajor' | 'preminor' | 'prepatch';
|
|
10
10
|
|
|
11
|
-
type Ctx = Omit<ManifestContext, 'build'>;
|
|
12
|
-
|
|
13
11
|
/**
|
|
14
12
|
* Utilities for working with package managers
|
|
15
13
|
*/
|
|
@@ -18,85 +16,71 @@ export class PackageManager {
|
|
|
18
16
|
/**
|
|
19
17
|
* Is a module already published
|
|
20
18
|
*/
|
|
21
|
-
static isPublished(
|
|
19
|
+
static isPublished(module: IndexedModule): ChildProcess {
|
|
22
20
|
let args: string[];
|
|
23
|
-
switch (
|
|
21
|
+
switch (Runtime.workspace.manager) {
|
|
24
22
|
case 'npm':
|
|
25
|
-
args = ['show', `${module.name}@${module.version}`, 'version', '--json'];
|
|
26
|
-
break;
|
|
27
23
|
case 'yarn':
|
|
28
|
-
|
|
29
|
-
break;
|
|
24
|
+
case 'pnpm': args = ['info', `${module.name}@${module.version}`, '--json']; break;
|
|
30
25
|
}
|
|
31
|
-
return spawn(
|
|
26
|
+
return spawn(Runtime.workspace.manager, args, { cwd: module.sourceFolder });
|
|
32
27
|
}
|
|
33
28
|
|
|
34
29
|
/**
|
|
35
30
|
* Validate published result
|
|
36
31
|
*/
|
|
37
|
-
static validatePublishedResult(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (!result.valid && !result.stderr.includes('E404')) {
|
|
41
|
-
throw new Error(result.stderr);
|
|
42
|
-
}
|
|
43
|
-
const item: (string[] | string) = result.stdout ? JSONUtil.parseSafe(result.stdout) : [];
|
|
44
|
-
const found = Array.isArray(item) ? item.pop() : item;
|
|
45
|
-
return !!found && found === module.version;
|
|
46
|
-
}
|
|
47
|
-
case 'yarn': {
|
|
48
|
-
const parsed = JSONUtil.parseSafe<{ data?: unknown }>(result.stdout);
|
|
49
|
-
return parsed.data !== undefined;
|
|
50
|
-
}
|
|
32
|
+
static validatePublishedResult(result: ExecutionResult<string>): boolean {
|
|
33
|
+
if (!result.valid && !result.stderr.includes('E404')) {
|
|
34
|
+
throw new Error(result.stderr);
|
|
51
35
|
}
|
|
36
|
+
|
|
37
|
+
const parsed = JSONUtil.parseSafe<{ data: { dist?: { integrity?: string } } }>(result.stdout || '{}');
|
|
38
|
+
return parsed.data?.dist?.integrity !== undefined;
|
|
52
39
|
}
|
|
53
40
|
|
|
54
41
|
/**
|
|
55
42
|
* Setting the version
|
|
56
43
|
*/
|
|
57
|
-
static
|
|
44
|
+
static version(modules: IndexedModule[], level: SemverLevel, preid?: string): ChildProcess {
|
|
58
45
|
const moduleArgs = modules.flatMap(module => ['-w', module.sourceFolder]);
|
|
59
46
|
let args: string[];
|
|
60
|
-
switch (
|
|
47
|
+
switch (Runtime.workspace.manager) {
|
|
61
48
|
case 'npm':
|
|
62
49
|
case 'yarn':
|
|
63
|
-
|
|
64
|
-
break;
|
|
50
|
+
case 'pnpm': args = ['version', '--no-workspaces-update', level, ...(preid ? ['--preid', preid] : [])]; break;
|
|
65
51
|
}
|
|
66
|
-
|
|
52
|
+
return spawn(Runtime.workspace.manager, [...args, ...moduleArgs], { cwd: Runtime.workspace.path, stdio: 'inherit' });
|
|
67
53
|
}
|
|
68
54
|
|
|
69
55
|
/**
|
|
70
56
|
* Dry-run packaging
|
|
71
57
|
*/
|
|
72
|
-
static dryRunPackaging(
|
|
58
|
+
static dryRunPackaging(module: IndexedModule): ChildProcess {
|
|
73
59
|
let args: string[];
|
|
74
|
-
switch (
|
|
60
|
+
switch (Runtime.workspace.manager) {
|
|
75
61
|
case 'npm':
|
|
76
62
|
case 'yarn':
|
|
77
|
-
|
|
78
|
-
break;
|
|
63
|
+
case 'pnpm': args = ['pack', '--dry-run']; break;
|
|
79
64
|
}
|
|
80
|
-
return spawn(
|
|
65
|
+
return spawn(Runtime.workspace.manager, args, { cwd: module.sourcePath });
|
|
81
66
|
}
|
|
82
67
|
|
|
83
68
|
/**
|
|
84
69
|
* Publish a module
|
|
85
70
|
*/
|
|
86
|
-
static publish(
|
|
71
|
+
static publish(module: IndexedModule, dryRun: boolean | undefined): ChildProcess {
|
|
87
72
|
if (dryRun) {
|
|
88
|
-
return this.dryRunPackaging(
|
|
73
|
+
return this.dryRunPackaging(module);
|
|
89
74
|
}
|
|
90
75
|
|
|
91
76
|
const versionTag = module.version.match(/^.*-(rc|alpha|beta|next)[.]\d+/)?.[1] ?? 'latest';
|
|
92
77
|
let args: string[];
|
|
93
|
-
switch (
|
|
78
|
+
switch (Runtime.workspace.manager) {
|
|
94
79
|
case 'npm':
|
|
95
80
|
case 'yarn':
|
|
96
|
-
|
|
97
|
-
break;
|
|
81
|
+
case 'pnpm': args = ['publish', '--tag', versionTag, '--access', 'public']; break;
|
|
98
82
|
}
|
|
99
|
-
return spawn(
|
|
83
|
+
return spawn(Runtime.workspace.manager, args, { cwd: module.sourcePath });
|
|
100
84
|
}
|
|
101
85
|
|
|
102
86
|
/**
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type CliCommandShape, CliCommand } from '@travetto/cli';
|
|
2
|
-
import { Runtime } from '@travetto/runtime';
|
|
3
2
|
|
|
4
3
|
import { PackageManager } from './bin/package-manager.ts';
|
|
5
4
|
import { RepoExecUtil } from './bin/exec.ts';
|
|
@@ -14,11 +13,11 @@ export class RepoPublishCommand implements CliCommandShape {
|
|
|
14
13
|
dryRun = true;
|
|
15
14
|
|
|
16
15
|
async main(): Promise<void> {
|
|
17
|
-
const published = await RepoExecUtil.execOnModules('workspace', module => PackageManager.isPublished(
|
|
16
|
+
const published = await RepoExecUtil.execOnModules('workspace', module => PackageManager.isPublished(module), {
|
|
18
17
|
filter: module => !!module.workspace && !module.internal,
|
|
19
18
|
progressMessage: (module) => `Checking published [%idx/%total] -- ${module?.name}`,
|
|
20
19
|
showStderr: false,
|
|
21
|
-
transformResult: (module, result) => PackageManager.validatePublishedResult(
|
|
20
|
+
transformResult: (module, result) => PackageManager.validatePublishedResult(result),
|
|
22
21
|
});
|
|
23
22
|
|
|
24
23
|
if (this.dryRun) {
|
|
@@ -26,7 +25,7 @@ export class RepoPublishCommand implements CliCommandShape {
|
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
await RepoExecUtil.execOnModules(
|
|
29
|
-
'workspace', module => PackageManager.publish(
|
|
28
|
+
'workspace', module => PackageManager.publish(module, this.dryRun),
|
|
30
29
|
{
|
|
31
30
|
progressMessage: (module) => `Published [%idx/%total] -- ${module?.name}`,
|
|
32
31
|
showStdout: false,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
2
|
|
|
3
3
|
import { CliModuleUtil, type CliCommandShape, CliCommand, CliScmUtil, type CliValidationError } from '@travetto/cli';
|
|
4
|
-
import { Runtime } from '@travetto/runtime';
|
|
4
|
+
import { ExecUtil, Runtime } from '@travetto/runtime';
|
|
5
5
|
|
|
6
6
|
import { PackageManager, type SemverLevel } from './bin/package-manager.ts';
|
|
7
7
|
|
|
@@ -46,7 +46,7 @@ export class RepoVersionCommand implements CliCommandShape {
|
|
|
46
46
|
throw new Error('No modules available for versioning');
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
await PackageManager.version(
|
|
49
|
+
await ExecUtil.getResult(PackageManager.version(modules, level, prefix));
|
|
50
50
|
|
|
51
51
|
const versions = await PackageManager.synchronizeVersions();
|
|
52
52
|
if (this.commit) {
|