@travetto/repo 3.0.3 → 3.1.0-rc.1

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
@@ -20,16 +20,15 @@ The versioning operation will find all the changed modules (and the modules that
20
20
 
21
21
  **Terminal: Version execution**
22
22
  ```bash
23
- $ trv repo:version
23
+ $ trv repo:version -h
24
24
 
25
- Please specify a level to continue
26
-
27
- Usage: trv repo:version [options] <level> [prefix]
25
+ Usage: repo:version [options] <level:string> [prefix:string]
28
26
 
29
27
  Options:
30
- -c, --no-changed Disables: Only version changed modules
31
- -f, --force Force operation, even in a dirty workspace
32
- -h, --help display help for command
28
+ --changed, --no-changed Only version changed modules (default: true)
29
+ -f, --force Force operation, even in a dirty workspace (default: false)
30
+ --commit, --no-commit Produce release commit message (default: true)
31
+ -h, --help display help for command
33
32
  ```
34
33
 
35
34
  Level is a standard semver level of: major, minor, patch or prerelease. The prefix argument only applies to the prerelease and allows for determining the prerelease level. For example:
@@ -48,7 +47,7 @@ Author: Travetto Framework <travetto.framework@gmail.com>
48
47
  Date: Thu Feb 23 17:51:37 2023 -0500
49
48
  Date: Thu Feb 23 17:51:37 2023 -0500
50
49
 
51
- Publish @travetto/app,@travetto/asset,@travetto/asset-rest,@travetto/auth,@travetto/auth-model,@travetto/auth-rest,@travetto/auth-rest-context,@travetto/auth-rest-jwt,@travetto/auth-rest-passport,@travetto/auth-rest-session,...
50
+ Publish @travetto/asset,@travetto/asset-rest,@travetto/auth,@travetto/auth-model,@travetto/auth-rest,@travetto/auth-rest-context,@travetto/auth-rest-jwt,@travetto/auth-rest-passport,@travetto/auth-rest-session,...
52
51
  ```
53
52
 
54
53
  ## CLI - Publish
@@ -58,18 +57,18 @@ The publish functionality is relatively naive, but consistent. The code will lo
58
57
  ```bash
59
58
  $ trv repo:publish -h
60
59
 
61
- Usage: repo:publish [options]
60
+ Usage: repo:publish [options]
62
61
 
63
62
  Options:
64
- -d, --no-dry-run Disables: Dry Run?
65
- -h, --help display help for command
63
+ --dry-run, --no-dry-run Dry Run? (default: true)
64
+ -h, --help display help for command
66
65
  ```
67
66
 
68
67
  By default the tool will execute a dry run only, and requires passing a flag to disable the dry run.
69
68
 
70
69
  **Terminal: Publishing changes**
71
70
  ```bash
72
- npx trv repo:publish -d
71
+ npx trv repo:publish --no-dry-run
73
72
  ```
74
73
 
75
74
  If no modules are currently changed, then the command will indicate there is no work to do, and exit gracefully.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/repo",
3
- "version": "3.0.3",
3
+ "version": "3.1.0-rc.1",
4
4
  "description": "Monorepo utilities",
5
5
  "keywords": [
6
6
  "travetto",
@@ -21,7 +21,7 @@
21
21
  "directory": "module/repo"
22
22
  },
23
23
  "dependencies": {
24
- "@travetto/cli": "^3.0.3"
24
+ "@travetto/cli": "^3.1.0-rc.1"
25
25
  },
26
26
  "peerDependenciesMeta": {
27
27
  "@travetto/cli": {
@@ -1,7 +1,7 @@
1
1
  import { ExecUtil, ExecutionOptions, ExecutionState, ExecutionResult } from '@travetto/base';
2
2
  import { IndexedModule, ManifestContext } from '@travetto/manifest';
3
3
 
4
- export type SemverLevel = 'minor' | 'patch' | 'major' | 'prerelease';
4
+ export type SemverLevel = 'minor' | 'patch' | 'major' | 'prerelease' | 'premajor' | 'preminor' | 'prepatch';
5
5
 
6
6
  /**
7
7
  * Utilities for working with package managers
@@ -1,28 +1,18 @@
1
- import { CliCommand, CliModuleUtil, OptionConfig } from '@travetto/cli';
1
+ import { CliCommandShape, CliCommand, CliModuleUtil } from '@travetto/cli';
2
2
  import { RootIndex } from '@travetto/manifest';
3
3
 
4
4
  import { PackageManager } from './bin/package-manager';
5
5
 
6
- type Options = {
7
- dryRun: OptionConfig<boolean>;
8
- };
9
-
10
6
  /**
11
- * `npx trv repo:publish`
12
- *
13
- * Publish all pending modules
14
- */
15
- export class RepoPublishCommand extends CliCommand<Options> {
16
-
17
- name = 'repo:publish';
7
+ * Publish all pending modules
8
+ */
9
+ @CliCommand()
10
+ export class RepoPublishCommand implements CliCommandShape {
18
11
 
19
- getOptions(): Options {
20
- return {
21
- dryRun: this.boolOption({ desc: 'Dry Run?', def: true })
22
- };
23
- }
12
+ /** Dry Run? */
13
+ dryRun = true;
24
14
 
25
- async action(...args: unknown[]): Promise<void> {
15
+ async main(): Promise<void> {
26
16
  const published = await CliModuleUtil.execOnModules('all', (mod, opts) => PackageManager.isPublished(RootIndex.manifest, mod, opts), {
27
17
  filter: mod => !!mod.local && !mod.internal,
28
18
  progressMessage: (mod) => `Checking published [%idx/%total] -- ${mod?.name}`,
@@ -30,12 +20,12 @@ export class RepoPublishCommand extends CliCommand<Options> {
30
20
  transformResult: (mod, res) => PackageManager.validatePublishedResult(RootIndex.manifest, mod, res),
31
21
  });
32
22
 
33
- if (this.cmd.dryRun) {
23
+ if (this.dryRun) {
34
24
  console.log('Unpublished modules', [...published.entries()].filter(x => !x[1]).map(([mod]) => mod.sourceFolder));
35
25
  }
36
26
 
37
27
  await CliModuleUtil.execOnModules(
38
- 'all', (mod, opts) => PackageManager.publish(RootIndex.manifest, mod, this.cmd.dryRun, opts),
28
+ 'all', (mod, opts) => PackageManager.publish(RootIndex.manifest, mod, this.dryRun, opts),
39
29
  {
40
30
  progressMessage: (mod) => `Published [%idx/%total] -- ${mod?.name}`,
41
31
  showStdout: false,
@@ -1,57 +1,43 @@
1
- import { CliCommand, CliScmUtil, OptionConfig } from '@travetto/cli';
1
+ import { CliCommandShape, CliCommand, CliScmUtil, CliValidationError } from '@travetto/cli';
2
2
  import { CliModuleUtil } from '@travetto/cli/src/module';
3
3
  import { RootIndex } from '@travetto/manifest';
4
4
 
5
5
  import { PackageManager, SemverLevel } from './bin/package-manager';
6
6
 
7
- type VersionOptions = {
8
- changed: OptionConfig<boolean>;
9
- force: OptionConfig<boolean>;
10
- };
11
-
12
7
  /**
13
- * `npx trv repo:version`
14
- *
15
- * Version all all changed dependencies
16
- */
17
- export class RepoVersionCommand extends CliCommand<VersionOptions> {
18
-
19
- name = 'repo:version';
20
-
21
- getArgs(): string {
22
- return '<level> [prefix]';
23
- }
24
-
25
- getOptions(): VersionOptions {
26
- return {
27
- changed: this.boolOption({ desc: 'Only version changed modules', def: true }),
28
- force: this.boolOption({ desc: 'Force operation, even in a dirty workspace', def: false })
29
- };
30
- }
31
-
32
- async action(level: SemverLevel, prefix?: string): Promise<void> {
33
- if (!level) {
34
- return this.showHelp('Please specify a level to continue');
35
- }
36
-
37
- if (!this.cmd.force && await CliScmUtil.isWorkspaceDirty()) {
38
- return this.showHelp('Cannot update versions with uncommitted changes');
8
+ * Version all changed dependencies
9
+ */
10
+ @CliCommand()
11
+ export class RepoVersionCommand implements CliCommandShape {
12
+ /** Only version changed modules */
13
+ changed = true;
14
+ /** Force operation, even in a dirty workspace */
15
+ force = false;
16
+ /** Produce release commit message */
17
+ commit = true;
18
+
19
+ async validate(...args: unknown[]): Promise<CliValidationError | undefined> {
20
+ if (!this.force && await CliScmUtil.isWorkspaceDirty()) {
21
+ return { message: 'Cannot update versions with uncommitted changes' };
39
22
  }
23
+ }
40
24
 
41
- const allModules = await CliModuleUtil.findModules(this.cmd.changed ? 'changed' : 'all');
25
+ async main(level: SemverLevel, prefix?: string): Promise<void> {
26
+ const allModules = await CliModuleUtil.findModules(this.changed ? 'changed' : 'all');
42
27
 
43
28
  const modules = allModules.filter(x => !x.internal);
44
29
 
45
30
  // Do we have valid changes?
46
31
  if (!modules.length) {
47
- console.error!('No modules available for versioning');
48
- return this.exit(1);
32
+ throw new Error('No modules available for versioning');
49
33
  }
50
34
 
51
35
  await PackageManager.version(RootIndex.manifest, modules, level, prefix);
52
36
 
53
37
  const versions = await CliModuleUtil.synchronizeModuleVersions();
54
-
55
- console.log!(await CliScmUtil.createCommit(`Publish ${modules.map(x => `${x.name}#${versions[x.name]?.replace('^', '') ?? x.version}`).join(',')}`));
38
+ if (this.commit) {
39
+ const commitMessage = `Publish ${modules.map(x => `${x.name}#${versions[x.name]?.replace('^', '') ?? x.version}`).join(',')}`;
40
+ console.log!(await CliScmUtil.createCommit(commitMessage));
41
+ }
56
42
  }
57
43
  }