@launch77/cli 1.7.2 → 1.7.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.
Files changed (145) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/infrastructure/package-resolver.test.js +9 -7
  3. package/dist/infrastructure/package-resolver.test.js.map +1 -1
  4. package/dist/modules/app/commands/create-app.d.ts.map +1 -1
  5. package/dist/modules/app/commands/create-app.js +1 -1
  6. package/dist/modules/app/commands/create-app.js.map +1 -1
  7. package/dist/modules/app/commands/delete-app.d.ts.map +1 -1
  8. package/dist/modules/app/commands/delete-app.js +1 -1
  9. package/dist/modules/app/commands/delete-app.js.map +1 -1
  10. package/dist/modules/app/lib/app-template-resolver.d.ts +1 -1
  11. package/dist/modules/app/lib/app-template-resolver.d.ts.map +1 -1
  12. package/dist/modules/app/lib/app-template-resolver.js +1 -1
  13. package/dist/modules/app/lib/app-template-resolver.js.map +1 -1
  14. package/dist/modules/app/services/app-svc.d.ts +1 -0
  15. package/dist/modules/app/services/app-svc.d.ts.map +1 -1
  16. package/dist/modules/app/services/app-svc.js +4 -4
  17. package/dist/modules/app/services/app-svc.js.map +1 -1
  18. package/dist/modules/app/services/manifest-svc.d.ts +1 -1
  19. package/dist/modules/app/services/manifest-svc.d.ts.map +1 -1
  20. package/dist/modules/catalog/commands/scan.d.ts.map +1 -1
  21. package/dist/modules/catalog/commands/scan.js +1 -1
  22. package/dist/modules/catalog/commands/scan.js.map +1 -1
  23. package/dist/modules/catalog/services/catalog-svc.d.ts.map +1 -1
  24. package/dist/modules/deploy/commands/deploy-init-action.js +1 -1
  25. package/dist/modules/deploy/commands/deploy-init-action.js.map +1 -1
  26. package/dist/modules/deploy/commands/deploy-logs-action.js +1 -1
  27. package/dist/modules/deploy/commands/deploy-logs-action.js.map +1 -1
  28. package/dist/modules/deploy/commands/deploy-status-action.js +1 -1
  29. package/dist/modules/deploy/commands/deploy-status-action.js.map +1 -1
  30. package/dist/modules/git/commands/git-connect.d.ts.map +1 -1
  31. package/dist/modules/git/commands/git-connect.js +3 -3
  32. package/dist/modules/git/commands/git-connect.js.map +1 -1
  33. package/dist/modules/library/commands/create-library.d.ts.map +1 -1
  34. package/dist/modules/library/commands/create-library.js +1 -1
  35. package/dist/modules/library/commands/create-library.js.map +1 -1
  36. package/dist/modules/library/commands/delete-library.d.ts.map +1 -1
  37. package/dist/modules/library/commands/delete-library.js +1 -1
  38. package/dist/modules/library/commands/delete-library.js.map +1 -1
  39. package/dist/modules/library/services/library-create-svc.js +1 -1
  40. package/dist/modules/library/services/library-create-svc.js.map +1 -1
  41. package/dist/modules/library/services/library-svc.d.ts +1 -0
  42. package/dist/modules/library/services/library-svc.d.ts.map +1 -1
  43. package/dist/modules/library/services/library-svc.js +3 -2
  44. package/dist/modules/library/services/library-svc.js.map +1 -1
  45. package/dist/modules/plugin/commands/delete-plugin.d.ts.map +1 -1
  46. package/dist/modules/plugin/commands/delete-plugin.js +1 -2
  47. package/dist/modules/plugin/commands/delete-plugin.js.map +1 -1
  48. package/dist/modules/plugin/commands/plugin-create.d.ts.map +1 -1
  49. package/dist/modules/plugin/commands/plugin-create.js +1 -1
  50. package/dist/modules/plugin/commands/plugin-create.js.map +1 -1
  51. package/dist/modules/plugin/commands/plugin-install.d.ts.map +1 -1
  52. package/dist/modules/plugin/commands/plugin-install.js +1 -2
  53. package/dist/modules/plugin/commands/plugin-install.js.map +1 -1
  54. package/dist/modules/plugin/index.d.ts +3 -3
  55. package/dist/modules/plugin/index.d.ts.map +1 -1
  56. package/dist/modules/plugin/index.js +2 -3
  57. package/dist/modules/plugin/index.js.map +1 -1
  58. package/dist/modules/plugin/lib/plugin-resolver.test.js +10 -6
  59. package/dist/modules/plugin/lib/plugin-resolver.test.js.map +1 -1
  60. package/dist/modules/plugin/services/plugin-create-service.d.ts +1 -0
  61. package/dist/modules/plugin/services/plugin-create-service.d.ts.map +1 -1
  62. package/dist/modules/plugin/services/plugin-create-service.js +4 -3
  63. package/dist/modules/plugin/services/plugin-create-service.js.map +1 -1
  64. package/dist/modules/plugin/services/plugin-svc.test.js +34 -30
  65. package/dist/modules/plugin/services/plugin-svc.test.js.map +1 -1
  66. package/dist/modules/release/commands/release-init.d.ts.map +1 -1
  67. package/dist/modules/release/commands/release-init.js +2 -2
  68. package/dist/modules/release/commands/release-init.js.map +1 -1
  69. package/dist/modules/release/services/release-service.d.ts.map +1 -1
  70. package/dist/modules/release/services/release-service.js +3 -3
  71. package/dist/modules/release/services/release-service.js.map +1 -1
  72. package/dist/modules/workspace/services/workspace-service.d.ts +1 -0
  73. package/dist/modules/workspace/services/workspace-service.d.ts.map +1 -1
  74. package/dist/modules/workspace/services/workspace-service.js +3 -2
  75. package/dist/modules/workspace/services/workspace-service.js.map +1 -1
  76. package/dist/templates/plugin/README.md.hbs +10 -0
  77. package/dist/templates/plugin/package.json.hbs +1 -1
  78. package/dist/templates/plugin/scripts/validate-plugin-json.js +13 -2
  79. package/dist/templates/workspace/.eslintignore +2 -1
  80. package/package.json +3 -3
  81. package/src/infrastructure/package-resolver.test.ts +9 -8
  82. package/src/modules/app/commands/create-app.ts +1 -1
  83. package/src/modules/app/commands/delete-app.ts +1 -1
  84. package/src/modules/app/lib/app-template-resolver.ts +1 -2
  85. package/src/modules/app/services/app-svc.ts +6 -7
  86. package/src/modules/app/services/manifest-svc.ts +1 -1
  87. package/src/modules/catalog/commands/scan.ts +1 -2
  88. package/src/modules/catalog/services/catalog-svc.ts +1 -1
  89. package/src/modules/deploy/commands/deploy-init-action.ts +1 -1
  90. package/src/modules/deploy/commands/deploy-logs-action.ts +1 -1
  91. package/src/modules/deploy/commands/deploy-status-action.ts +1 -1
  92. package/src/modules/git/commands/git-connect.ts +3 -3
  93. package/src/modules/library/commands/create-library.ts +1 -1
  94. package/src/modules/library/commands/delete-library.ts +1 -1
  95. package/src/modules/library/services/library-create-svc.ts +1 -1
  96. package/src/modules/library/services/library-svc.ts +3 -2
  97. package/src/modules/plugin/commands/delete-plugin.ts +1 -3
  98. package/src/modules/plugin/commands/plugin-create.ts +1 -1
  99. package/src/modules/plugin/commands/plugin-install.ts +1 -3
  100. package/src/modules/plugin/index.ts +4 -6
  101. package/src/modules/plugin/lib/plugin-resolver.test.ts +10 -7
  102. package/src/modules/plugin/services/plugin-create-service.ts +4 -3
  103. package/src/modules/plugin/services/plugin-svc.test.ts +52 -32
  104. package/src/modules/release/commands/release-init.ts +2 -2
  105. package/src/modules/release/services/release-service.ts +4 -3
  106. package/src/modules/workspace/services/workspace-service.ts +3 -2
  107. package/templates/plugin/README.md.hbs +10 -0
  108. package/templates/plugin/package.json.hbs +1 -1
  109. package/templates/plugin/scripts/validate-plugin-json.js +13 -2
  110. package/templates/workspace/.eslintignore +2 -1
  111. package/dist/infrastructure/npm-package.d.ts +0 -42
  112. package/dist/infrastructure/npm-package.d.ts.map +0 -1
  113. package/dist/infrastructure/npm-package.js +0 -46
  114. package/dist/infrastructure/npm-package.js.map +0 -1
  115. package/dist/infrastructure/npm.d.ts +0 -9
  116. package/dist/infrastructure/npm.d.ts.map +0 -1
  117. package/dist/infrastructure/npm.js +0 -17
  118. package/dist/infrastructure/npm.js.map +0 -1
  119. package/dist/infrastructure/package-resolver.d.ts +0 -117
  120. package/dist/infrastructure/package-resolver.d.ts.map +0 -1
  121. package/dist/infrastructure/package-resolver.js +0 -170
  122. package/dist/infrastructure/package-resolver.js.map +0 -1
  123. package/dist/modules/plugin/errors/plugin-errors.d.ts +0 -51
  124. package/dist/modules/plugin/errors/plugin-errors.d.ts.map +0 -1
  125. package/dist/modules/plugin/errors/plugin-errors.js +0 -130
  126. package/dist/modules/plugin/errors/plugin-errors.js.map +0 -1
  127. package/dist/modules/plugin/lib/plugin-resolver.d.ts +0 -14
  128. package/dist/modules/plugin/lib/plugin-resolver.d.ts.map +0 -1
  129. package/dist/modules/plugin/lib/plugin-resolver.js +0 -36
  130. package/dist/modules/plugin/lib/plugin-resolver.js.map +0 -1
  131. package/dist/modules/plugin/services/plugin-svc.d.ts +0 -42
  132. package/dist/modules/plugin/services/plugin-svc.d.ts.map +0 -1
  133. package/dist/modules/plugin/services/plugin-svc.js +0 -257
  134. package/dist/modules/plugin/services/plugin-svc.js.map +0 -1
  135. package/dist/modules/plugin/types/plugin-types.d.ts +0 -25
  136. package/dist/modules/plugin/types/plugin-types.d.ts.map +0 -1
  137. package/dist/modules/plugin/types/plugin-types.js +0 -2
  138. package/dist/modules/plugin/types/plugin-types.js.map +0 -1
  139. package/src/infrastructure/npm-package.ts +0 -73
  140. package/src/infrastructure/npm.ts +0 -18
  141. package/src/infrastructure/package-resolver.ts +0 -223
  142. package/src/modules/plugin/errors/plugin-errors.ts +0 -145
  143. package/src/modules/plugin/lib/plugin-resolver.ts +0 -41
  144. package/src/modules/plugin/services/plugin-svc.ts +0 -303
  145. package/src/modules/plugin/types/plugin-types.ts +0 -29
@@ -1,10 +1,10 @@
1
1
  import * as path from 'path'
2
2
  import { fileURLToPath } from 'url'
3
3
 
4
+ import { NpmService } from '@launch77/plugin-runtime'
4
5
  import { execa } from 'execa'
5
6
 
6
7
  import * as filesystem from '../../../infrastructure/filesystem.js'
7
- import * as npm from '../../../infrastructure/npm.js'
8
8
  import { WorkspaceAlreadyExistsError } from '../errors/workspace-errors.js'
9
9
  import { validateWorkspaceName } from '../utils/workspace-validators.js'
10
10
 
@@ -12,6 +12,7 @@ import type { InitWorkspaceRequest, InitWorkspaceResult } from '../types/workspa
12
12
  import type { Ora } from 'ora'
13
13
 
14
14
  export class WorkspaceService {
15
+ private npmService = new NpmService()
15
16
  async initWorkspace(request: InitWorkspaceRequest, cwd: string, spinner?: Ora): Promise<InitWorkspaceResult> {
16
17
  const { name } = request
17
18
 
@@ -50,7 +51,7 @@ export class WorkspaceService {
50
51
  // 8. Install dependencies
51
52
  console.log('\nInstalling dependencies...')
52
53
  try {
53
- await npm.install(workspacePath)
54
+ await this.npmService.install(workspacePath)
54
55
  console.log('✓ Dependencies installed')
55
56
  } catch (error) {
56
57
  console.warn('⚠ Warning: npm install failed:', error instanceof Error ? error.message : String(error))
@@ -34,6 +34,16 @@ npm run typecheck
34
34
 
35
35
  The `templates/` directory contains files that will be copied to the target application when this plugin is installed. Add any template files your plugin needs here.
36
36
 
37
+ ## Showcase Page (Optional)
38
+
39
+ To create an examples/documentation page for your plugin:
40
+
41
+ 1. Add `"showcaseUrl": "/plugins/{{packageFolderName}}"` to `plugin.json`
42
+ 2. Create a page at `templates/src/app/plugins/{{packageFolderName}}/page.tsx`
43
+ 3. The page will appear on the `/plugins` discovery page when installed
44
+
45
+ See the [Plugin Development Guide](https://github.com/launch77/docs/plugin-development.md) for details.
46
+
37
47
  ## License
38
48
 
39
49
  UNLICENSED
@@ -21,7 +21,7 @@
21
21
  "typecheck": "tsc --noEmit"
22
22
  },
23
23
  "dependencies": {
24
- "@launch77/plugin-runtime": "^0.1.0",
24
+ "@launch77/plugin-runtime": "^0.3.2",
25
25
  "chalk": "^5.3.0"
26
26
  },
27
27
  "devDependencies": {
@@ -1,8 +1,19 @@
1
1
  #!/usr/bin/env node
2
- import { validatePluginConsistencyOrThrow } from '@launch77/plugin-runtime'
2
+ import { PluginService } from '@launch77/plugin-runtime'
3
3
 
4
4
  // Validate that library versions in package.json match plugin.json
5
5
  // This runs before every build to catch version mismatches early
6
- validatePluginConsistencyOrThrow(process.cwd()).catch((error) => {
6
+ async function validatePlugin() {
7
+ const pluginService = new PluginService()
8
+ const result = await pluginService.validatePluginConsistency(process.cwd())
9
+
10
+ if (!result.isValid) {
11
+ console.error('Plugin consistency validation failed:', result.errors?.join(', '))
12
+ process.exit(1)
13
+ }
14
+ }
15
+
16
+ validatePlugin().catch((error) => {
17
+ console.error('Validation error:', error)
7
18
  process.exit(1)
8
19
  })
@@ -4,4 +4,5 @@ dist
4
4
  .turbo
5
5
  coverage
6
6
  *.config.js
7
- .eslintrc.js
7
+ .eslintrc.js
8
+ next-env.d.ts
@@ -1,42 +0,0 @@
1
- /**
2
- * Options for downloading an npm package
3
- */
4
- export interface DownloadNpmPackageOptions {
5
- /** The npm package name to download */
6
- packageName: string;
7
- /** The workspace root directory where node_modules will be */
8
- workspaceRoot: string;
9
- /** Optional logger function for status messages */
10
- logger?: (message: string) => void;
11
- }
12
- /**
13
- * Result of downloading an npm package
14
- */
15
- export interface DownloadNpmPackageResult {
16
- /** Full path to the downloaded package in node_modules */
17
- packagePath: string;
18
- /** The package name that was downloaded */
19
- packageName: string;
20
- }
21
- /**
22
- * Download and install an npm package to workspace node_modules
23
- *
24
- * This function:
25
- * - Runs `npm install {packageName} --save-dev` in the workspace root
26
- * - Adds the package to workspace package.json devDependencies
27
- * - Returns the path to the installed package in node_modules
28
- *
29
- * @param options - Download options
30
- * @returns The path to the installed package
31
- * @throws NpmInstallationError if the download fails
32
- *
33
- * @example
34
- * const result = await downloadNpmPackage({
35
- * packageName: '@launch77-shared/plugin-release',
36
- * workspaceRoot: '/path/to/workspace',
37
- * logger: (msg) => console.log(msg)
38
- * })
39
- * // result.packagePath: '/path/to/workspace/node_modules/@launch77-shared/plugin-release'
40
- */
41
- export declare function downloadNpmPackage(options: DownloadNpmPackageOptions): Promise<DownloadNpmPackageResult>;
42
- //# sourceMappingURL=npm-package.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"npm-package.d.ts","sourceRoot":"","sources":["../../src/infrastructure/npm-package.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,uCAAuC;IACvC,WAAW,EAAE,MAAM,CAAA;IACnB,8DAA8D;IAC9D,aAAa,EAAE,MAAM,CAAA;IACrB,mDAAmD;IACnD,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,0DAA0D;IAC1D,WAAW,EAAE,MAAM,CAAA;IACnB,2CAA2C;IAC3C,WAAW,EAAE,MAAM,CAAA;CACpB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAwB9G"}
@@ -1,46 +0,0 @@
1
- import * as path from 'path';
2
- import { execa } from 'execa';
3
- import { NpmInstallationError } from '../modules/plugin/errors/plugin-errors.js';
4
- /**
5
- * Download and install an npm package to workspace node_modules
6
- *
7
- * This function:
8
- * - Runs `npm install {packageName} --save-dev` in the workspace root
9
- * - Adds the package to workspace package.json devDependencies
10
- * - Returns the path to the installed package in node_modules
11
- *
12
- * @param options - Download options
13
- * @returns The path to the installed package
14
- * @throws NpmInstallationError if the download fails
15
- *
16
- * @example
17
- * const result = await downloadNpmPackage({
18
- * packageName: '@launch77-shared/plugin-release',
19
- * workspaceRoot: '/path/to/workspace',
20
- * logger: (msg) => console.log(msg)
21
- * })
22
- * // result.packagePath: '/path/to/workspace/node_modules/@launch77-shared/plugin-release'
23
- */
24
- export async function downloadNpmPackage(options) {
25
- const { packageName, workspaceRoot, logger } = options;
26
- if (logger) {
27
- logger(`Installing from npm: ${packageName}...`);
28
- }
29
- try {
30
- // Install the npm package to the workspace
31
- await execa('npm', ['install', packageName, '--save-dev'], {
32
- cwd: workspaceRoot,
33
- stdio: 'pipe', // Capture output for clean logging
34
- });
35
- // Return path to installed package in node_modules
36
- const packagePath = path.join(workspaceRoot, 'node_modules', packageName);
37
- return {
38
- packagePath,
39
- packageName,
40
- };
41
- }
42
- catch (error) {
43
- throw new NpmInstallationError(packageName, error instanceof Error ? error : undefined);
44
- }
45
- }
46
- //# sourceMappingURL=npm-package.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"npm-package.js","sourceRoot":"","sources":["../../src/infrastructure/npm-package.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAE5B,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAE7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAwBhF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,OAAkC;IACzE,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,OAAO,CAAA;IAEtD,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,CAAC,wBAAwB,WAAW,KAAK,CAAC,CAAA;IAClD,CAAC;IAED,IAAI,CAAC;QACH,2CAA2C;QAC3C,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC,SAAS,EAAE,WAAW,EAAE,YAAY,CAAC,EAAE;YACzD,GAAG,EAAE,aAAa;YAClB,KAAK,EAAE,MAAM,EAAE,mCAAmC;SACnD,CAAC,CAAA;QAEF,mDAAmD;QACnD,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,cAAc,EAAE,WAAW,CAAC,CAAA;QAEzE,OAAO;YACL,WAAW;YACX,WAAW;SACZ,CAAA;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,oBAAoB,CAAC,WAAW,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;IACzF,CAAC;AACH,CAAC"}
@@ -1,9 +0,0 @@
1
- /**
2
- * Run npm install in a directory
3
- */
4
- export declare function runNpmInstall(cwd: string): Promise<void>;
5
- /**
6
- * Alias for runNpmInstall
7
- */
8
- export declare function install(cwd: string): Promise<void>;
9
- //# sourceMappingURL=npm.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"npm.d.ts","sourceRoot":"","sources":["../../src/infrastructure/npm.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAsB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAK9D;AAED;;GAEG;AACH,wBAAsB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAExD"}
@@ -1,17 +0,0 @@
1
- import { execa } from 'execa';
2
- /**
3
- * Run npm install in a directory
4
- */
5
- export async function runNpmInstall(cwd) {
6
- await execa('npm', ['install'], {
7
- cwd,
8
- stdio: 'pipe',
9
- });
10
- }
11
- /**
12
- * Alias for runNpmInstall
13
- */
14
- export async function install(cwd) {
15
- await runNpmInstall(cwd);
16
- }
17
- //# sourceMappingURL=npm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"npm.js","sourceRoot":"","sources":["../../src/infrastructure/npm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAE7B;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,GAAW;IAC7C,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC,SAAS,CAAC,EAAE;QAC9B,GAAG;QACH,KAAK,EAAE,MAAM;KACd,CAAC,CAAA;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,GAAW;IACvC,MAAM,aAAa,CAAC,GAAG,CAAC,CAAA;AAC1B,CAAC"}
@@ -1,117 +0,0 @@
1
- import type { ValidationResult } from '@launch77/plugin-runtime';
2
- /**
3
- * Base interface for package resolution results
4
- */
5
- export interface PackageResolution {
6
- /** The source of the package */
7
- source: 'local' | 'npm';
8
- /** The resolved name/package to use */
9
- resolvedName: string;
10
- /** The local path if source is 'local' */
11
- localPath?: string;
12
- /** The npm package name if source is 'npm' */
13
- npmPackage?: string;
14
- /** The version from package.json (required for local packages, undefined for npm until installed) */
15
- version?: string;
16
- }
17
- /**
18
- * Abstract base class for resolving Launch77 packages
19
- *
20
- * Provides generic resolution logic for finding packages in:
21
- * 1. Local workspace directory (e.g., plugins/, app-templates/)
22
- * 2. npm packages with configured prefix (e.g., @launch77-shared/plugin-*, @launch77-shared/app-template-*)
23
- *
24
- * Concrete implementations must provide:
25
- * - Folder name for local resolution
26
- * - Package prefix for npm resolution
27
- * - Verification logic to validate local packages
28
- */
29
- export declare abstract class PackageResolver {
30
- /**
31
- * Get the local folder name where packages of this type are stored
32
- * @example 'plugins' or 'app-templates'
33
- */
34
- protected abstract getFolderName(): string;
35
- /**
36
- * Get the npm package prefix for unscoped packages
37
- * @example '@launch77-shared/plugin-' or '@launch77-shared/app-template-'
38
- */
39
- protected abstract getPackagePrefix(): string;
40
- /**
41
- * Verify that a local package is valid and complete
42
- * @param localPath - The local directory path to verify
43
- * @returns true if the package is valid, false otherwise
44
- */
45
- protected abstract verify(localPath: string): Promise<boolean>;
46
- /**
47
- * Validate package input name
48
- *
49
- * Accepts:
50
- * - Unscoped names (e.g., "release", "my-package")
51
- * - Scoped npm packages (e.g., "@ibm/package-name")
52
- *
53
- * Rejects:
54
- * - Invalid formats
55
- * - Empty strings
56
- * - Names with invalid characters
57
- *
58
- * @param name - The package name to validate
59
- * @returns ValidationResult with isValid and optional error message
60
- *
61
- * @example
62
- * validateInput('release') // { isValid: true }
63
- * validateInput('@ibm/analytics') // { isValid: true }
64
- * validateInput('@invalid') // { isValid: false, error: '...' }
65
- */
66
- validateInput(name: string): ValidationResult;
67
- /**
68
- * Convert an unscoped package name to an npm package name
69
- *
70
- * Rules:
71
- * - Unscoped names: prefix with configured package prefix
72
- * - Scoped names: use as-is
73
- *
74
- * @param name - The package name (must be validated first)
75
- * @returns The npm package name
76
- *
77
- * @example
78
- * toNpmPackageName('release') // '@launch77-shared/plugin-release' (for PluginResolver)
79
- * toNpmPackageName('@ibm/analytics') // '@ibm/analytics'
80
- */
81
- toNpmPackageName(name: string): string;
82
- /**
83
- * Read version from package.json
84
- * @param packagePath - The path to the package directory
85
- * @returns The version string from package.json
86
- * @throws If package.json doesn't exist, can't be read, or is missing the version field
87
- */
88
- private readVersion;
89
- /**
90
- * Resolve package location from name
91
- *
92
- * Resolution order:
93
- * 1. Check local workspace directory (configured by getFolderName())
94
- * 2. Verify local package is valid (using verify())
95
- * 3. Fall back to npm package name (with configured prefix)
96
- * 4. Read version from package.json (if available)
97
- *
98
- * @param name - The package name to resolve
99
- * @param workspaceRoot - The workspace root directory
100
- * @returns PackageResolution with source, resolved location, and version
101
- *
102
- * @example
103
- * // Local package found
104
- * await resolveLocation('my-package', '/workspace')
105
- * // { source: 'local', resolvedName: 'my-package', localPath: '/workspace/plugins/my-package', version: '1.0.0' }
106
- *
107
- * // Not found locally, resolve to npm
108
- * await resolveLocation('release', '/workspace')
109
- * // { source: 'npm', resolvedName: 'release', npmPackage: '@launch77-shared/plugin-release' }
110
- *
111
- * // Scoped package always resolves to npm
112
- * await resolveLocation('@ibm/analytics', '/workspace')
113
- * // { source: 'npm', resolvedName: '@ibm/analytics', npmPackage: '@ibm/analytics' }
114
- */
115
- resolveLocation(name: string, workspaceRoot: string): Promise<PackageResolution>;
116
- }
117
- //# sourceMappingURL=package-resolver.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"package-resolver.d.ts","sourceRoot":"","sources":["../../src/infrastructure/package-resolver.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAEhE;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,gCAAgC;IAChC,MAAM,EAAE,OAAO,GAAG,KAAK,CAAA;IACvB,uCAAuC;IACvC,YAAY,EAAE,MAAM,CAAA;IACpB,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,8CAA8C;IAC9C,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,qGAAqG;IACrG,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED;;;;;;;;;;;GAWG;AACH,8BAAsB,eAAe;IACnC;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,aAAa,IAAI,MAAM;IAE1C;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,gBAAgB,IAAI,MAAM;IAE7C;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAE9D;;;;;;;;;;;;;;;;;;;OAmBG;IACH,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB;IA8B7C;;;;;;;;;;;;;OAaG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAYtC;;;;;OAKG;YACW,WAAW;IAkBzB;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACG,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAyCvF"}
@@ -1,170 +0,0 @@
1
- import * as path from 'path';
2
- import { parsePluginName, isValidNpmPackageName } from '@launch77/plugin-runtime';
3
- import fs from 'fs-extra';
4
- /**
5
- * Abstract base class for resolving Launch77 packages
6
- *
7
- * Provides generic resolution logic for finding packages in:
8
- * 1. Local workspace directory (e.g., plugins/, app-templates/)
9
- * 2. npm packages with configured prefix (e.g., @launch77-shared/plugin-*, @launch77-shared/app-template-*)
10
- *
11
- * Concrete implementations must provide:
12
- * - Folder name for local resolution
13
- * - Package prefix for npm resolution
14
- * - Verification logic to validate local packages
15
- */
16
- export class PackageResolver {
17
- /**
18
- * Validate package input name
19
- *
20
- * Accepts:
21
- * - Unscoped names (e.g., "release", "my-package")
22
- * - Scoped npm packages (e.g., "@ibm/package-name")
23
- *
24
- * Rejects:
25
- * - Invalid formats
26
- * - Empty strings
27
- * - Names with invalid characters
28
- *
29
- * @param name - The package name to validate
30
- * @returns ValidationResult with isValid and optional error message
31
- *
32
- * @example
33
- * validateInput('release') // { isValid: true }
34
- * validateInput('@ibm/analytics') // { isValid: true }
35
- * validateInput('@invalid') // { isValid: false, error: '...' }
36
- */
37
- validateInput(name) {
38
- if (!name || name.trim().length === 0) {
39
- return {
40
- isValid: false,
41
- error: 'Package name cannot be empty',
42
- };
43
- }
44
- const trimmedName = name.trim();
45
- // Parse the name to determine type and validate
46
- //TODO: move/rename parsePluginName() to parsePackageName()
47
- const parsed = parsePluginName(trimmedName);
48
- if (!parsed.isValid) {
49
- return {
50
- isValid: false,
51
- error: parsed.error,
52
- };
53
- }
54
- // If it's scoped, it must be a valid npm package name
55
- if (parsed.type === 'scoped') {
56
- return isValidNpmPackageName(trimmedName);
57
- }
58
- // Unscoped names are valid for both local and npm
59
- return { isValid: true };
60
- }
61
- /**
62
- * Convert an unscoped package name to an npm package name
63
- *
64
- * Rules:
65
- * - Unscoped names: prefix with configured package prefix
66
- * - Scoped names: use as-is
67
- *
68
- * @param name - The package name (must be validated first)
69
- * @returns The npm package name
70
- *
71
- * @example
72
- * toNpmPackageName('release') // '@launch77-shared/plugin-release' (for PluginResolver)
73
- * toNpmPackageName('@ibm/analytics') // '@ibm/analytics'
74
- */
75
- toNpmPackageName(name) {
76
- const trimmedName = name.trim();
77
- // If already scoped, use as-is
78
- if (trimmedName.startsWith('@')) {
79
- return trimmedName;
80
- }
81
- // Otherwise, convert using configured prefix
82
- return `${this.getPackagePrefix()}${trimmedName}`;
83
- }
84
- /**
85
- * Read version from package.json
86
- * @param packagePath - The path to the package directory
87
- * @returns The version string from package.json
88
- * @throws If package.json doesn't exist, can't be read, or is missing the version field
89
- */
90
- async readVersion(packagePath) {
91
- const packageJsonPath = path.join(packagePath, 'package.json');
92
- try {
93
- const packageJson = await fs.readJson(packageJsonPath);
94
- if (!packageJson.version) {
95
- throw new Error(`Invalid package structure: package.json at ${packagePath} is missing required version field. ` + `All Launch77 packages must include a valid package.json with a version field.`);
96
- }
97
- return packageJson.version;
98
- }
99
- catch (error) {
100
- // Re-throw our own error messages
101
- if (error instanceof Error && error.message.includes('Invalid package structure')) {
102
- throw error;
103
- }
104
- // File not found or invalid JSON
105
- throw new Error(`Invalid package structure: package.json not found or invalid at ${packagePath}. ` + `All Launch77 packages must include a valid package.json with a version field.`);
106
- }
107
- }
108
- /**
109
- * Resolve package location from name
110
- *
111
- * Resolution order:
112
- * 1. Check local workspace directory (configured by getFolderName())
113
- * 2. Verify local package is valid (using verify())
114
- * 3. Fall back to npm package name (with configured prefix)
115
- * 4. Read version from package.json (if available)
116
- *
117
- * @param name - The package name to resolve
118
- * @param workspaceRoot - The workspace root directory
119
- * @returns PackageResolution with source, resolved location, and version
120
- *
121
- * @example
122
- * // Local package found
123
- * await resolveLocation('my-package', '/workspace')
124
- * // { source: 'local', resolvedName: 'my-package', localPath: '/workspace/plugins/my-package', version: '1.0.0' }
125
- *
126
- * // Not found locally, resolve to npm
127
- * await resolveLocation('release', '/workspace')
128
- * // { source: 'npm', resolvedName: 'release', npmPackage: '@launch77-shared/plugin-release' }
129
- *
130
- * // Scoped package always resolves to npm
131
- * await resolveLocation('@ibm/analytics', '/workspace')
132
- * // { source: 'npm', resolvedName: '@ibm/analytics', npmPackage: '@ibm/analytics' }
133
- */
134
- async resolveLocation(name, workspaceRoot) {
135
- const trimmedName = name.trim();
136
- const parsed = parsePluginName(trimmedName);
137
- // If scoped, always use npm (local packages are never scoped)
138
- if (parsed.type === 'scoped') {
139
- return {
140
- source: 'npm',
141
- resolvedName: trimmedName,
142
- npmPackage: trimmedName,
143
- };
144
- }
145
- // Check local workspace directory
146
- const localPath = path.join(workspaceRoot, this.getFolderName(), trimmedName);
147
- const localExists = await fs.pathExists(localPath);
148
- if (localExists) {
149
- // Verify it's a valid package
150
- const isValid = await this.verify(localPath);
151
- if (isValid) {
152
- const version = await this.readVersion(localPath);
153
- return {
154
- source: 'local',
155
- resolvedName: trimmedName,
156
- localPath,
157
- version,
158
- };
159
- }
160
- }
161
- // Not found locally or invalid, resolve to npm package
162
- const npmPackage = this.toNpmPackageName(trimmedName);
163
- return {
164
- source: 'npm',
165
- resolvedName: trimmedName,
166
- npmPackage,
167
- };
168
- }
169
- }
170
- //# sourceMappingURL=package-resolver.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"package-resolver.js","sourceRoot":"","sources":["../../src/infrastructure/package-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAE5B,OAAO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I,WAAW,EAAE,CAAC;YAChB,8BAA8B;YAC9B,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;YAE5C,IAAI,OAAO,EAAE,CAAC;gBACZ,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;gBACjD,OAAO;oBACL,MAAM,EAAE,OAAO;oBACf,YAAY,EAAE,WAAW;oBACzB,SAAS;oBACT,OAAO;iBACR,CAAA;YACH,CAAC;QACH,CAAC;QAED,uDAAuD;QACvD,MAAM,UAAU,GAAG,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAA;QAErD,OAAO;YACL,MAAM,EAAE,KAAK;YACb,YAAY,EAAE,WAAW;YACzB,UAAU;SACX,CAAA;IACH,CAAC;CACF"}
@@ -1,51 +0,0 @@
1
- export declare class PluginNotFoundError extends Error {
2
- constructor(pluginName: string);
3
- }
4
- export declare class InvalidPluginContextError extends Error {
5
- constructor(message: string);
6
- }
7
- /**
8
- * Factory function to create standardized InvalidPluginContextError
9
- * for when plugin:install is run outside of a package directory
10
- */
11
- export declare function createInvalidContextError(currentLocation: string): InvalidPluginContextError;
12
- /**
13
- * Error when plugin.json is missing the required 'targets' field
14
- */
15
- export declare class MissingPluginTargetsError extends Error {
16
- constructor(pluginName: string);
17
- }
18
- /**
19
- * Factory function to create error when plugin targets don't match current location
20
- */
21
- export declare function createInvalidTargetError(pluginName: string, currentTarget: string, allowedTargets: string[]): InvalidPluginContextError;
22
- export declare class PluginInstallationError extends Error {
23
- readonly cause?: Error | undefined;
24
- constructor(message: string, cause?: Error | undefined);
25
- }
26
- /**
27
- * Error when plugin resolution fails
28
- */
29
- export declare class PluginResolutionError extends Error {
30
- constructor(pluginName: string, reason: string);
31
- }
32
- /**
33
- * Error when npm package installation fails
34
- */
35
- export declare class NpmInstallationError extends Error {
36
- readonly cause?: Error | undefined;
37
- constructor(packageName: string, cause?: Error | undefined);
38
- }
39
- /**
40
- * Error when plugin directory is not found for deletion
41
- */
42
- export declare class PluginDirectoryNotFoundError extends Error {
43
- constructor(pluginName: string, expectedPath: string);
44
- }
45
- /**
46
- * Error when plugin name validation fails
47
- */
48
- export declare class InvalidPluginNameError extends Error {
49
- constructor(message: string);
50
- }
51
- //# sourceMappingURL=plugin-errors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin-errors.d.ts","sourceRoot":"","sources":["../../../../src/modules/plugin/errors/plugin-errors.ts"],"names":[],"mappings":"AAAA,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,UAAU,EAAE,MAAM;CAM/B;AAED,qBAAa,yBAA0B,SAAQ,KAAK;gBACtC,OAAO,EAAE,MAAM;CAI5B;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,eAAe,EAAE,MAAM,GAAG,yBAAyB,CAa5F;AAED;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,KAAK;gBACtC,UAAU,EAAE,MAAM;CAgB/B;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,yBAAyB,CAwBvI;AAED,qBAAa,uBAAwB,SAAQ,KAAK;aAG9B,KAAK,CAAC,EAAE,KAAK;gBAD7B,OAAO,EAAE,MAAM,EACC,KAAK,CAAC,EAAE,KAAK,YAAA;CAKhC;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAI/C;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;aAG3B,KAAK,CAAC,EAAE,KAAK;gBAD7B,WAAW,EAAE,MAAM,EACH,KAAK,CAAC,EAAE,KAAK,YAAA;CAYhC;AAED;;GAEG;AACH,qBAAa,4BAA6B,SAAQ,KAAK;gBACzC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;CAIrD;AAED;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,OAAO,EAAE,MAAM;CAI5B"}