@launch77/cli 1.4.3 → 1.5.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/CHANGELOG.md +19 -0
- package/dist/cli.js +1 -4
- package/dist/cli.js.map +1 -1
- package/dist/infrastructure/npm-package.d.ts +42 -0
- package/dist/infrastructure/npm-package.d.ts.map +1 -0
- package/dist/infrastructure/npm-package.js +46 -0
- package/dist/infrastructure/npm-package.js.map +1 -0
- package/dist/infrastructure/package-resolver.d.ts +117 -0
- package/dist/infrastructure/package-resolver.d.ts.map +1 -0
- package/dist/infrastructure/package-resolver.js +170 -0
- package/dist/infrastructure/package-resolver.js.map +1 -0
- package/dist/infrastructure/package-resolver.test.d.ts +2 -0
- package/dist/infrastructure/package-resolver.test.d.ts.map +1 -0
- package/dist/infrastructure/package-resolver.test.js +251 -0
- package/dist/infrastructure/package-resolver.test.js.map +1 -0
- package/dist/infrastructure/template.d.ts +0 -1
- package/dist/infrastructure/template.d.ts.map +1 -1
- package/dist/infrastructure/template.js.map +1 -1
- package/dist/modules/app/commands/create-app.d.ts.map +1 -1
- package/dist/modules/app/commands/create-app.js +14 -15
- package/dist/modules/app/commands/create-app.js.map +1 -1
- package/dist/modules/app/commands/delete-app.js +1 -1
- package/dist/modules/app/commands/delete-app.js.map +1 -1
- package/dist/modules/app/commands/validate-manifest.d.ts.map +1 -1
- package/dist/modules/app/commands/validate-manifest.js +0 -1
- package/dist/modules/app/commands/validate-manifest.js.map +1 -1
- package/dist/modules/app/index.d.ts +1 -2
- package/dist/modules/app/index.d.ts.map +1 -1
- package/dist/modules/app/index.js +0 -1
- package/dist/modules/app/index.js.map +1 -1
- package/dist/modules/app/lib/app-template-resolver.d.ts +14 -0
- package/dist/modules/app/lib/app-template-resolver.d.ts.map +1 -0
- package/dist/modules/app/lib/app-template-resolver.js +51 -0
- package/dist/modules/app/lib/app-template-resolver.js.map +1 -0
- package/dist/modules/app/lib/manifest-schema.d.ts +0 -7
- package/dist/modules/app/lib/manifest-schema.d.ts.map +1 -1
- package/dist/modules/app/lib/manifest-schema.js +0 -2
- package/dist/modules/app/lib/manifest-schema.js.map +1 -1
- package/dist/modules/app/services/app-svc.d.ts +2 -1
- package/dist/modules/app/services/app-svc.d.ts.map +1 -1
- package/dist/modules/app/services/app-svc.js +77 -12
- package/dist/modules/app/services/app-svc.js.map +1 -1
- package/dist/modules/app/services/manifest-svc.d.ts +2 -2
- package/dist/modules/app/services/manifest-svc.d.ts.map +1 -1
- package/dist/modules/app/services/manifest-svc.js +9 -50
- package/dist/modules/app/services/manifest-svc.js.map +1 -1
- package/dist/modules/app/types/app-types.d.ts +2 -5
- package/dist/modules/app/types/app-types.d.ts.map +1 -1
- package/dist/modules/app/types/app-types.js +1 -4
- package/dist/modules/app/types/app-types.js.map +1 -1
- package/dist/modules/catalog/commands/scan.js +3 -3
- package/dist/modules/catalog/commands/scan.js.map +1 -1
- package/dist/modules/catalog/services/catalog-svc.d.ts +2 -2
- package/dist/modules/catalog/services/catalog-svc.d.ts.map +1 -1
- package/dist/modules/catalog/services/catalog-svc.js +2 -2
- package/dist/modules/catalog/services/catalog-svc.js.map +1 -1
- package/dist/modules/deploy/commands/deploy-init-action.d.ts.map +1 -1
- package/dist/modules/deploy/commands/deploy-init-action.js +21 -20
- package/dist/modules/deploy/commands/deploy-init-action.js.map +1 -1
- package/dist/modules/deploy/commands/deploy-logs-action.d.ts.map +1 -1
- package/dist/modules/deploy/commands/deploy-logs-action.js +16 -13
- package/dist/modules/deploy/commands/deploy-logs-action.js.map +1 -1
- package/dist/modules/deploy/commands/deploy-status-action.d.ts.map +1 -1
- package/dist/modules/deploy/commands/deploy-status-action.js +16 -13
- package/dist/modules/deploy/commands/deploy-status-action.js.map +1 -1
- package/dist/modules/plugin/lib/plugin-resolver.d.ts +10 -72
- package/dist/modules/plugin/lib/plugin-resolver.d.ts.map +1 -1
- package/dist/modules/plugin/lib/plugin-resolver.js +23 -115
- package/dist/modules/plugin/lib/plugin-resolver.js.map +1 -1
- package/dist/modules/plugin/lib/plugin-resolver.test.js +45 -39
- package/dist/modules/plugin/lib/plugin-resolver.test.js.map +1 -1
- package/dist/modules/plugin/services/plugin-svc.d.ts +2 -0
- package/dist/modules/plugin/services/plugin-svc.d.ts.map +1 -1
- package/dist/modules/plugin/services/plugin-svc.js +24 -19
- package/dist/modules/plugin/services/plugin-svc.js.map +1 -1
- package/dist/modules/plugin/services/plugin-svc.test.js +12 -6
- package/dist/modules/plugin/services/plugin-svc.test.js.map +1 -1
- package/dist/templates/plugin/package.json.hbs +1 -1
- package/dist/templates/plugin/plugin.json.hbs +1 -3
- package/dist/utils/validation.d.ts +3 -7
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +7 -31
- package/dist/utils/validation.js.map +1 -1
- package/package.json +1 -1
- package/src/cli.ts +1 -4
- package/src/infrastructure/npm-package.ts +73 -0
- package/src/infrastructure/package-resolver.test.ts +313 -0
- package/src/infrastructure/package-resolver.ts +223 -0
- package/src/infrastructure/template.ts +0 -1
- package/src/modules/app/commands/create-app.ts +14 -18
- package/src/modules/app/commands/delete-app.ts +1 -1
- package/src/modules/app/commands/validate-manifest.ts +0 -1
- package/src/modules/app/index.ts +1 -2
- package/src/modules/app/lib/app-template-resolver.ts +56 -0
- package/src/modules/app/lib/manifest-schema.ts +0 -5
- package/src/modules/app/services/app-svc.ts +89 -13
- package/src/modules/app/services/manifest-svc.ts +8 -57
- package/src/modules/app/types/app-types.ts +2 -9
- package/src/modules/catalog/commands/scan.ts +3 -3
- package/src/modules/catalog/services/catalog-svc.ts +4 -4
- package/src/modules/deploy/commands/deploy-init-action.ts +23 -20
- package/src/modules/deploy/commands/deploy-logs-action.ts +19 -13
- package/src/modules/deploy/commands/deploy-status-action.ts +19 -13
- package/src/modules/plugin/lib/plugin-resolver.test.ts +48 -39
- package/src/modules/plugin/lib/plugin-resolver.ts +22 -141
- package/src/modules/plugin/services/plugin-svc.test.ts +12 -6
- package/src/modules/plugin/services/plugin-svc.ts +27 -18
- package/src/utils/validation.ts +10 -38
- package/templates/plugin/package.json.hbs +1 -1
- package/templates/plugin/plugin.json.hbs +1 -3
- package/dist/modules/app/commands/generate-manifest.d.ts +0 -3
- package/dist/modules/app/commands/generate-manifest.d.ts.map +0 -1
- package/dist/modules/app/commands/generate-manifest.js +0 -62
- package/dist/modules/app/commands/generate-manifest.js.map +0 -1
- package/dist/modules/startup/commands/create-startup.d.ts +0 -3
- package/dist/modules/startup/commands/create-startup.d.ts.map +0 -1
- package/dist/modules/startup/commands/create-startup.js +0 -43
- package/dist/modules/startup/commands/create-startup.js.map +0 -1
- package/dist/modules/startup/errors/startup-errors.d.ts +0 -13
- package/dist/modules/startup/errors/startup-errors.d.ts.map +0 -1
- package/dist/modules/startup/errors/startup-errors.js +0 -25
- package/dist/modules/startup/errors/startup-errors.js.map +0 -1
- package/dist/modules/startup/index.d.ts +0 -5
- package/dist/modules/startup/index.d.ts.map +0 -1
- package/dist/modules/startup/index.js +0 -7
- package/dist/modules/startup/index.js.map +0 -1
- package/dist/modules/startup/services/startup-service.d.ts +0 -7
- package/dist/modules/startup/services/startup-service.d.ts.map +0 -1
- package/dist/modules/startup/services/startup-service.js +0 -43
- package/dist/modules/startup/services/startup-service.js.map +0 -1
- package/dist/modules/startup/types/startup-types.d.ts +0 -8
- package/dist/modules/startup/types/startup-types.d.ts.map +0 -1
- package/dist/modules/startup/types/startup-types.js +0 -2
- package/dist/modules/startup/types/startup-types.js.map +0 -1
- package/dist/modules/startup/utils/startup-validators.d.ts +0 -8
- package/dist/modules/startup/utils/startup-validators.d.ts.map +0 -1
- package/dist/modules/startup/utils/startup-validators.js +0 -17
- package/dist/modules/startup/utils/startup-validators.js.map +0 -1
- package/dist/templates/startup/apps/.gitkeep +0 -8
- package/dist/utils/monorepo.d.ts +0 -19
- package/dist/utils/monorepo.d.ts.map +0 -1
- package/dist/utils/monorepo.js +0 -100
- package/dist/utils/monorepo.js.map +0 -1
- package/src/modules/app/commands/generate-manifest.ts +0 -75
- package/src/modules/startup/commands/create-startup.ts +0 -53
- package/src/modules/startup/errors/startup-errors.ts +0 -23
- package/src/modules/startup/index.ts +0 -11
- package/src/modules/startup/services/startup-service.ts +0 -57
- package/src/modules/startup/types/startup-types.ts +0 -8
- package/src/modules/startup/utils/startup-validators.ts +0 -19
- package/src/utils/monorepo.ts +0 -137
- package/templates/startup/apps/.gitkeep +0 -8
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import * as path from 'path'
|
|
2
|
-
import { fileURLToPath } from 'url'
|
|
3
|
-
|
|
4
|
-
import * as filesystem from '../../../infrastructure/filesystem.js'
|
|
5
|
-
import { StartupAlreadyExistsError, NotInMonorepoRootError } from '../errors/startup-errors.js'
|
|
6
|
-
import { validateStartupName } from '../utils/startup-validators.js'
|
|
7
|
-
|
|
8
|
-
import type { MonorepoContext } from '../../../utils/monorepo.js'
|
|
9
|
-
import type { CreateStartupRequest, CreateStartupResult } from '../types/startup-types.js'
|
|
10
|
-
|
|
11
|
-
export class StartupService {
|
|
12
|
-
async createStartup(request: CreateStartupRequest, context: MonorepoContext): Promise<CreateStartupResult> {
|
|
13
|
-
const { name } = request
|
|
14
|
-
|
|
15
|
-
// 1. Validate name
|
|
16
|
-
validateStartupName(name)
|
|
17
|
-
|
|
18
|
-
// 2. Verify we found the monorepo
|
|
19
|
-
if (!context.isValid) {
|
|
20
|
-
throw new NotInMonorepoRootError()
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// 3. Determine startup path
|
|
24
|
-
const startupsDir = path.join(context.monorepoRoot, 'startups')
|
|
25
|
-
const startupPath = path.join(startupsDir, name)
|
|
26
|
-
|
|
27
|
-
// 4. Check if startup already exists
|
|
28
|
-
if (await filesystem.exists(startupPath)) {
|
|
29
|
-
throw new StartupAlreadyExistsError(name, startupPath)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// 5. Ensure startups directory exists
|
|
33
|
-
await filesystem.ensureDir(startupsDir)
|
|
34
|
-
|
|
35
|
-
// 6. Copy template
|
|
36
|
-
const templatePath = this.getTemplatePath()
|
|
37
|
-
await filesystem.copy(templatePath, startupPath)
|
|
38
|
-
|
|
39
|
-
return {
|
|
40
|
-
startupPath,
|
|
41
|
-
name,
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
private getTemplatePath(): string {
|
|
46
|
-
const __filename = fileURLToPath(import.meta.url)
|
|
47
|
-
const __dirname = path.dirname(__filename)
|
|
48
|
-
|
|
49
|
-
// From src/modules/startup/services/ or dist/modules/startup/services/ up to cli root
|
|
50
|
-
const isDev = __filename.includes('/src/')
|
|
51
|
-
const cliRoot = isDev
|
|
52
|
-
? path.join(__dirname, '../../../..') // src/modules/startup/services -> cli root
|
|
53
|
-
: path.join(__dirname, '../../../..') // dist/modules/startup/services -> cli root
|
|
54
|
-
|
|
55
|
-
return path.join(cliRoot, 'templates/startup')
|
|
56
|
-
}
|
|
57
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { InvalidStartupNameError } from '../errors/startup-errors.js'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Validate startup name format
|
|
5
|
-
* - Must be lowercase
|
|
6
|
-
* - Can only contain lowercase letters, numbers, and hyphens
|
|
7
|
-
* - Cannot contain spaces, uppercase, underscores, periods, or special characters
|
|
8
|
-
*/
|
|
9
|
-
export function validateStartupName(name: string): void {
|
|
10
|
-
if (!name || name.trim().length === 0) {
|
|
11
|
-
throw new Error('Startup name cannot be empty')
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const validPattern = /^[a-z0-9-]+$/
|
|
15
|
-
|
|
16
|
-
if (!validPattern.test(name)) {
|
|
17
|
-
throw new InvalidStartupNameError(name)
|
|
18
|
-
}
|
|
19
|
-
}
|
package/src/utils/monorepo.ts
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import * as path from 'path'
|
|
2
|
-
|
|
3
|
-
import fs from 'fs-extra'
|
|
4
|
-
|
|
5
|
-
export type LocationType = 'monorepo-root' | 'startup-root' | 'startup-app' | 'unknown'
|
|
6
|
-
|
|
7
|
-
export interface MonorepoContext {
|
|
8
|
-
isValid: boolean
|
|
9
|
-
location: LocationType
|
|
10
|
-
monorepoRoot: string
|
|
11
|
-
appsDir: string | null
|
|
12
|
-
// Specific context info
|
|
13
|
-
startupName?: string
|
|
14
|
-
appName?: string
|
|
15
|
-
packageName?: string
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const MONOREPO_ROOT_MARKER = '.launch-monorepo-root.md'
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Check if a directory is the monorepo root by looking for the marker file
|
|
22
|
-
*/
|
|
23
|
-
async function isMonorepoRoot(dir: string): Promise<boolean> {
|
|
24
|
-
const markerPath = path.join(dir, MONOREPO_ROOT_MARKER)
|
|
25
|
-
return await fs.pathExists(markerPath)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Find the monorepo root by traversing up from a starting directory
|
|
30
|
-
* Looks for .launch-monorepo-root.md marker file
|
|
31
|
-
*/
|
|
32
|
-
async function findMonorepoRoot(startDir: string): Promise<string | null> {
|
|
33
|
-
let currentDir = path.resolve(startDir)
|
|
34
|
-
const rootDir = path.parse(currentDir).root
|
|
35
|
-
|
|
36
|
-
while (currentDir !== rootDir) {
|
|
37
|
-
if (await isMonorepoRoot(currentDir)) {
|
|
38
|
-
return currentDir
|
|
39
|
-
}
|
|
40
|
-
currentDir = path.dirname(currentDir)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return null
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
interface ParsedLocation {
|
|
47
|
-
location: LocationType
|
|
48
|
-
startupName?: string
|
|
49
|
-
appName?: string
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Parse the directory structure to determine location context
|
|
54
|
-
* Based on patterns:
|
|
55
|
-
* - startups/[name] → startup-root
|
|
56
|
-
* - startups/[name]/apps/[app] → startup-app
|
|
57
|
-
* - (empty or root) → monorepo-root
|
|
58
|
-
*/
|
|
59
|
-
function parseLocationFromPath(cwdPath: string, monorepoRoot: string): ParsedLocation {
|
|
60
|
-
const relativePath = path.relative(monorepoRoot, cwdPath)
|
|
61
|
-
|
|
62
|
-
// At monorepo root
|
|
63
|
-
if (!relativePath || relativePath === '.') {
|
|
64
|
-
return { location: 'monorepo-root' }
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const parts = relativePath.split(path.sep)
|
|
68
|
-
|
|
69
|
-
// startups/[name]/...
|
|
70
|
-
if (parts[0] === 'startups' && parts.length >= 2) {
|
|
71
|
-
const startupName = parts[1]
|
|
72
|
-
|
|
73
|
-
// startups/[name]/apps/[app]
|
|
74
|
-
if (parts.length >= 4 && parts[2] === 'apps') {
|
|
75
|
-
return {
|
|
76
|
-
location: 'startup-app',
|
|
77
|
-
startupName,
|
|
78
|
-
appName: parts[3],
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// startups/[name]
|
|
83
|
-
return {
|
|
84
|
-
location: 'startup-root',
|
|
85
|
-
startupName,
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return { location: 'unknown' }
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Determine the apps directory based on location context
|
|
94
|
-
* Returns null for invalid locations (e.g., monorepo-root, unknown)
|
|
95
|
-
*/
|
|
96
|
-
function getAppsDir(monorepoRoot: string, location: LocationType, startupName?: string): string | null {
|
|
97
|
-
if (location === 'startup-root' || location === 'startup-app') {
|
|
98
|
-
return path.join(monorepoRoot, 'startups', startupName!, 'apps')
|
|
99
|
-
}
|
|
100
|
-
return null
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Detect the monorepo context from the current working directory
|
|
105
|
-
*
|
|
106
|
-
* @deprecated Use detectLaunch77Context() from launch77-context.ts instead.
|
|
107
|
-
* This function is maintained for legacy monorepo structure only.
|
|
108
|
-
* New workspaces created with `launch77 init` should use the new context system.
|
|
109
|
-
*/
|
|
110
|
-
export async function detectMonorepoContext(cwd: string): Promise<MonorepoContext> {
|
|
111
|
-
const resolvedCwd = path.resolve(cwd)
|
|
112
|
-
|
|
113
|
-
// Find the monorepo root
|
|
114
|
-
const monorepoRoot = await findMonorepoRoot(resolvedCwd)
|
|
115
|
-
|
|
116
|
-
if (!monorepoRoot) {
|
|
117
|
-
return {
|
|
118
|
-
isValid: false,
|
|
119
|
-
location: 'unknown',
|
|
120
|
-
monorepoRoot: '',
|
|
121
|
-
appsDir: null,
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// Parse the directory structure to determine location
|
|
126
|
-
const parsed = parseLocationFromPath(resolvedCwd, monorepoRoot)
|
|
127
|
-
const appsDir = getAppsDir(monorepoRoot, parsed.location, parsed.startupName)
|
|
128
|
-
|
|
129
|
-
return {
|
|
130
|
-
isValid: true,
|
|
131
|
-
location: parsed.location,
|
|
132
|
-
monorepoRoot,
|
|
133
|
-
appsDir,
|
|
134
|
-
startupName: parsed.startupName,
|
|
135
|
-
appName: parsed.appName,
|
|
136
|
-
}
|
|
137
|
-
}
|