@tsparticles/cli 3.3.0 → 3.3.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/.planning/codebase/ARCHITECTURE.md +100 -3
- package/.planning/codebase/CONCERNS.md +102 -3
- package/.planning/codebase/CONVENTIONS.md +96 -3
- package/.planning/codebase/INTEGRATIONS.md +73 -3
- package/.planning/codebase/STACK.md +82 -8
- package/.planning/codebase/STRUCTURE.md +104 -3
- package/.planning/codebase/TESTING.md +138 -3
- package/dist/build/build-prettier.d.ts +2 -2
- package/dist/build/build-prettier.js +11 -11
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/renovate.json +3 -0
- package/src/build/build-prettier.ts +10 -12
|
@@ -1,3 +1,100 @@
|
|
|
1
|
-
Architecture
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# Architecture
|
|
2
|
+
|
|
3
|
+
**Analysis Date:** 2026-03-08
|
|
4
|
+
|
|
5
|
+
## Pattern Overview
|
|
6
|
+
|
|
7
|
+
**Overall:** Modular CLI application structured as command modules (command-per-file) with utility layers for filesystem and template operations.
|
|
8
|
+
|
|
9
|
+
**Key Characteristics:**
|
|
10
|
+
|
|
11
|
+
- Command-oriented boundaries implemented with `commander` (commands registered in `src/cli.ts` and `src/create/*`, `src/build/*`).
|
|
12
|
+
- Utilities are centralized under `src/utils/` for file operations, templating, and string manipulation.
|
|
13
|
+
- Build-related logic is under `src/build/` and creation/template generation logic under `src/create/`.
|
|
14
|
+
|
|
15
|
+
## Layers
|
|
16
|
+
|
|
17
|
+
**CLI / Entry Layer:**
|
|
18
|
+
|
|
19
|
+
- Purpose: Expose CLI commands and wiring.
|
|
20
|
+
- Location: `src/cli.ts`
|
|
21
|
+
- Contains: Program initialization, command registration (`build`, `create`).
|
|
22
|
+
- Depends on: `src/build/*`, `src/create/*`.
|
|
23
|
+
- Used by: End users invoking the installed binary.
|
|
24
|
+
|
|
25
|
+
**Command Implementations:**
|
|
26
|
+
|
|
27
|
+
- Purpose: Implement individual subcommands for build and create flows.
|
|
28
|
+
- Location: `src/create/*` (e.g. `src/create/create.ts`, `src/create/preset/*`, `src/create/plugin/*`, `src/create/shape/*`) and `src/build/*` (e.g. `src/build/build.ts`, `src/build/build-*.ts`).
|
|
29
|
+
- Contains: Command definitions, argument parsing (uses `commander`), orchestration of utilities.
|
|
30
|
+
- Depends on: `src/utils/*` for filesystem and templating, `fs-extra`, `prettier`, `webpack` where needed.
|
|
31
|
+
|
|
32
|
+
**Utilities / Core Logic:**
|
|
33
|
+
|
|
34
|
+
- Purpose: Reusable helpers for file operations, token replacement, template manipulation, and string utilities.
|
|
35
|
+
- Location: `src/utils/` (`file-utils.ts`, `template-utils.ts`, `string-utils.ts`).
|
|
36
|
+
- Contains: `replaceTokensInFile`, `runInstall`, `runBuild`, copy filter helpers, string transforms.
|
|
37
|
+
- Depends on: `fs-extra`, `lookpath`, `child_process` (`exec`).
|
|
38
|
+
|
|
39
|
+
**Files & Templates:**
|
|
40
|
+
|
|
41
|
+
- Purpose: Template resources used to scaffold projects.
|
|
42
|
+
- Location: `files/` (e.g., `files/create-shape`, `files/create-preset`, `files/create-plugin`, `files/empty-project`).
|
|
43
|
+
|
|
44
|
+
## Data Flow
|
|
45
|
+
|
|
46
|
+
Create flow (example `create shape`):
|
|
47
|
+
|
|
48
|
+
1. User runs CLI: `tsparticles-cli create shape <dest>` (`src/cli.ts` -> `src/create/create.ts` -> `src/create/shape/*`).
|
|
49
|
+
2. Command handler calls `createShapeTemplate` in `src/create/shape/create-shape.ts`.
|
|
50
|
+
3. `createShapeTemplate` copies template files from `files/create-shape` to destination using `fs-extra` and `template-utils.copyEmptyTemplateFiles`.
|
|
51
|
+
4. Token replacement and file updates are performed using `src/utils/file-utils.ts` functions like `replaceTokensInFile` and helpers in `src/utils/template-utils.ts`.
|
|
52
|
+
5. Optional lifecycle commands `runInstall` and `runBuild` invoke external commands (`npm install`, `npm run build`) via `child_process.exec` if `npm` is present (checked via `lookpath`).
|
|
53
|
+
|
|
54
|
+
State Management:
|
|
55
|
+
|
|
56
|
+
- Stateless CLI; state is the filesystem and created project files. No in-memory long-lived state across runs.
|
|
57
|
+
|
|
58
|
+
## Key Abstractions
|
|
59
|
+
|
|
60
|
+
**Template Updater:**
|
|
61
|
+
|
|
62
|
+
- Purpose: Replace tokens and update produced scaffold files.
|
|
63
|
+
- Examples: `src/utils/file-utils.ts` (`replaceTokensInFile`), `src/utils/template-utils.ts` (`updatePackageFile`, `updateWebpackFile`, `updatePackageDistFile`).
|
|
64
|
+
- Pattern: Imperative token-replacement using regexes and file writes.
|
|
65
|
+
|
|
66
|
+
**Command Modules:**
|
|
67
|
+
|
|
68
|
+
- Purpose: Each subcommand is an isolated module exposing a `Command` (from `commander`).
|
|
69
|
+
- Examples: `src/create/create.ts`, `src/build/build.ts`, `src/create/shape/create-shape.ts`.
|
|
70
|
+
|
|
71
|
+
## Entry Points
|
|
72
|
+
|
|
73
|
+
**CLI Entrypoint:**
|
|
74
|
+
|
|
75
|
+
- Location: `src/cli.ts`
|
|
76
|
+
- Triggers: Node process when user runs `tsparticles-cli` or package `bin` mapping.
|
|
77
|
+
- Responsibilities: Read package version (`package.json`), register commands and parse args.
|
|
78
|
+
|
|
79
|
+
## Error Handling
|
|
80
|
+
|
|
81
|
+
Strategy:
|
|
82
|
+
|
|
83
|
+
- Try/catch around file operations and external command execution; errors logged to console with `console.error` and boolean success values returned (e.g., `src/build/*` functions return `Promise<boolean>`). Examples: `src/build/build-prettier.ts`, `src/build/build-bundle.ts`.
|
|
84
|
+
|
|
85
|
+
Patterns:
|
|
86
|
+
|
|
87
|
+
- Propagate failures by throwing or returning `false` and logging details.
|
|
88
|
+
- `replaceTokensInFiles` performs read/replace/write with no specialized rollback.
|
|
89
|
+
|
|
90
|
+
## Cross-Cutting Concerns
|
|
91
|
+
|
|
92
|
+
Logging: `console.log`, `console.warn`, `console.error` used across `src/build/*` and `src/utils/*`.
|
|
93
|
+
|
|
94
|
+
Validation: Input validation is minimal — `commander` performs CLI argument parsing; `getDestinationDir` validates destination directory emptiness in `src/utils/file-utils.ts`.
|
|
95
|
+
|
|
96
|
+
Authentication: Not applicable; tool is local and does not call external authenticated services.
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
_Architecture analysis: 2026-03-08_
|
|
@@ -1,3 +1,102 @@
|
|
|
1
|
-
Concerns
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# Codebase Concerns
|
|
2
|
+
|
|
3
|
+
**Analysis Date:** 2026-03-08
|
|
4
|
+
|
|
5
|
+
## Tech Debt
|
|
6
|
+
|
|
7
|
+
1. Minimal input validation and transactional safety when writing files
|
|
8
|
+
|
|
9
|
+
- Issue: `replaceTokensInFiles` and other template-updating functions perform read/replace/write in-place without atomic writes or rollback. A failed intermediate step can leave partially updated files.
|
|
10
|
+
- Files: `src/utils/file-utils.ts`, `src/utils/template-utils.ts`, `src/create/shape/create-shape.ts`
|
|
11
|
+
- Impact: Corrupted template output when an operation fails mid-flow; harder to recover from errors.
|
|
12
|
+
- Fix approach: Write to temporary files and rename atomically (use `fs-extra` `outputFile` + `move`), or create the target in a staging directory and move into destination once all transformations succeed.
|
|
13
|
+
|
|
14
|
+
2. Running external commands directly in template flow (`npm install`, `npm run build`)
|
|
15
|
+
|
|
16
|
+
- Issue: `runInstall` and `runBuild` call `exec("npm install")` and `exec("npm run build")` without timeouts or stdout/stderr piping; they rely on `lookpath` only.
|
|
17
|
+
- Files: `src/utils/template-utils.ts` (functions `runInstall`, `runBuild`)
|
|
18
|
+
- Impact: Tests or CI running on environments lacking `npm` may silently skip or hang if `lookpath` returns true but command misbehaves; poor control over failure modes.
|
|
19
|
+
- Fix approach: Use spawned child process with streaming logs and a configurable timeout, or provide a dry-run flag. In tests, mock these exec calls to avoid long-running operations.
|
|
20
|
+
|
|
21
|
+
3. Prettier plugin compatibility workaround
|
|
22
|
+
|
|
23
|
+
- Issue: `src/build/build-prettier.ts` contains a TODO disabling Prettier check for `prettier-plugin-multiline-arrays` compatibility with Prettier 3.0.0.
|
|
24
|
+
- Files: `src/build/build-prettier.ts` (line with TODO)
|
|
25
|
+
- Impact: Formatting checks may be inconsistent across CI and local dev environments.
|
|
26
|
+
- Fix approach: Update dependencies to versions compatible with Prettier 3.x or pin Prettier to a compatible 2.x in CI until plugins are updated. Add a CI check that fails early with a clear error message.
|
|
27
|
+
|
|
28
|
+
## Known Bugs
|
|
29
|
+
|
|
30
|
+
None detected by static analysis in the repository. Tests pass in CI (workflow present) but no failing patterns discovered in code scan.
|
|
31
|
+
|
|
32
|
+
## Security Considerations
|
|
33
|
+
|
|
34
|
+
1. Running external commands with user-provided template inputs
|
|
35
|
+
|
|
36
|
+
- Risk: If destination paths or template tokens contain malicious content, shell commands executed via `exec` could be abused.
|
|
37
|
+
- Files: `src/utils/template-utils.ts` (`runInstall`, `runBuild`), `src/utils/file-utils.ts` (token replacement using regex from code, not user input directly).
|
|
38
|
+
- Current mitigation: `exec` is invoked with static commands (`npm install`) and not interpolated with user-supplied strings. `replaceTokensInFile` uses regex replacements defined in code.
|
|
39
|
+
- Recommendation: Avoid invoking shell with interpolated user input. If needed, sanitize inputs and prefer `spawn` with argument arrays.
|
|
40
|
+
|
|
41
|
+
2. Reading git remote URL via `exec` in `getRepositoryUrl`
|
|
42
|
+
|
|
43
|
+
- Risk: `exec` result is returned directly; if git not present it rejects.
|
|
44
|
+
- Files: `src/utils/file-utils.ts` (`getRepositoryUrl`)
|
|
45
|
+
- Recommendation: Wrap with timeout and sanitize output before using it in template substitution.
|
|
46
|
+
|
|
47
|
+
## Performance Bottlenecks
|
|
48
|
+
|
|
49
|
+
1. Synchronous/serial file traversal in prettify
|
|
50
|
+
|
|
51
|
+
- Problem: `prettier` formatting in `prettifySrc` iterates files sequentially (`for await (const file of klaw(srcPath))`), performing `prettier.resolveConfig` per file which may be expensive.
|
|
52
|
+
- Files: `src/build/build-prettier.ts`
|
|
53
|
+
- Cause: Recomputing config and formatting each file sequentially.
|
|
54
|
+
- Improvement path: Resolve config once outside the loop, run formatting in parallel batches, and avoid repeated IO for options.
|
|
55
|
+
|
|
56
|
+
## Fragile Areas
|
|
57
|
+
|
|
58
|
+
1. Regex-based token replacement
|
|
59
|
+
|
|
60
|
+
- Files: `src/utils/file-utils.ts`, `src/utils/template-utils.ts`, `src/create/*` token replacement usage
|
|
61
|
+
- Why fragile: Regexes operate on file contents and can unintentionally match similar substrings; no schema validation after replacement.
|
|
62
|
+
- Safe modification: Add tests for each token replacement case, and perform replacements against structured JSON (for `package.json`) using AST parsing where possible.
|
|
63
|
+
- Test coverage: Token replacement used heavily but tests exercise many flows; add more unit tests for edge cases.
|
|
64
|
+
|
|
65
|
+
## Scaling Limits
|
|
66
|
+
|
|
67
|
+
Not applicable: CLI scaffolding and local build tool; not intended for high-concurrency server workloads.
|
|
68
|
+
|
|
69
|
+
## Dependencies at Risk
|
|
70
|
+
|
|
71
|
+
1. Prettier plugin `prettier-plugin-multiline-arrays`
|
|
72
|
+
|
|
73
|
+
- Risk: Incompatibility with Prettier 3.x noted in `src/build/build-prettier.ts` TODO.
|
|
74
|
+
- Impact: Formatting and CI checks could be disrupted.
|
|
75
|
+
- Migration plan: Upgrade plugin or pin Prettier; monitor plugin releases.
|
|
76
|
+
|
|
77
|
+
## Missing Critical Features
|
|
78
|
+
|
|
79
|
+
1. No centralized logging or telemetry
|
|
80
|
+
|
|
81
|
+
- Problem: Uses `console.*` directly; no centralized structured logs for debugging CI or for library consumers.
|
|
82
|
+
- Blocks: Advanced observability and consistent log levels.
|
|
83
|
+
|
|
84
|
+
## Test Coverage Gaps
|
|
85
|
+
|
|
86
|
+
1. Lack of mocks for external process execution
|
|
87
|
+
|
|
88
|
+
- What's not tested: Behavior of `runInstall`/`runBuild` when `npm` present and when the commands fail.
|
|
89
|
+
- Files: `src/utils/template-utils.ts` and tests in `tests/` currently avoid actually running `npm` by relying on environment; but there are no unit tests mocking `exec`.
|
|
90
|
+
- Risk: Breakage during publish/cmd execution might not be caught in unit tests.
|
|
91
|
+
- Priority: Medium — add tests that stub `child_process.exec` and `lookpath` to verify behavior on success and failure.
|
|
92
|
+
|
|
93
|
+
2. Token replacement edge cases
|
|
94
|
+
|
|
95
|
+
- What's not tested: Regex collisions and JSON-encoded fields in `package.json` and `package.dist.json` replacements.
|
|
96
|
+
- Files: `src/utils/file-utils.ts`, `src/utils/template-utils.ts`
|
|
97
|
+
- Risk: Incorrect package metadata produced for scaffolds.
|
|
98
|
+
- Priority: High — add unit tests that run replacements on fixture files with edge-case tokens.
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
_Concerns audit: 2026-03-08_
|
|
@@ -1,3 +1,96 @@
|
|
|
1
|
-
Conventions
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# Coding Conventions
|
|
2
|
+
|
|
3
|
+
**Analysis Date:** 2026-03-08
|
|
4
|
+
|
|
5
|
+
## Naming Patterns
|
|
6
|
+
|
|
7
|
+
Files:
|
|
8
|
+
|
|
9
|
+
- Source files are placed under feature directories (e.g., `src/create/shape/create-shape.ts`). Use descriptive names matching the feature.
|
|
10
|
+
|
|
11
|
+
Functions:
|
|
12
|
+
|
|
13
|
+
- Use camelCase for function names (e.g., `createShapeTemplate` in `src/create/shape/create-shape.ts`, `replaceTokensInFile` in `src/utils/file-utils.ts`).
|
|
14
|
+
|
|
15
|
+
Variables:
|
|
16
|
+
|
|
17
|
+
- Use camelCase for variables and constants. TypeScript types use PascalCase.
|
|
18
|
+
|
|
19
|
+
Types:
|
|
20
|
+
|
|
21
|
+
- Interfaces and types use PascalCase (e.g., `ReplaceTokensOptions`, `ReplaceTokensData` in `src/utils/file-utils.ts`).
|
|
22
|
+
|
|
23
|
+
## Code Style
|
|
24
|
+
|
|
25
|
+
Formatting:
|
|
26
|
+
|
|
27
|
+
- Prettier is the formatting tool; root `package.json` sets `prettier` to `@tsparticles/prettier-config`. Formatting settings are applied in `src/build/build-prettier.ts` (printWidth 120, tabWidth 2, endOfLine lf).
|
|
28
|
+
|
|
29
|
+
Linting:
|
|
30
|
+
|
|
31
|
+
- ESLint config in `eslint.config.js` extends `@tsparticles/eslint-config`. Linting is enforced in `package.json` scripts (`lint`, `lint:ci`) and CI runs `pnpm run lint:ci` in `node.js-ci.yml`.
|
|
32
|
+
|
|
33
|
+
## Import Organization
|
|
34
|
+
|
|
35
|
+
Order:
|
|
36
|
+
|
|
37
|
+
1. Node built-ins (e.g., `path`, `fs-extra` import as `fs`)
|
|
38
|
+
2. External dependencies (e.g., `commander`, `prompts`)
|
|
39
|
+
3. Internal modules (relative imports under `src/`)
|
|
40
|
+
|
|
41
|
+
Examples: `src/cli.ts` imports `buildCommand` and `createCommand` from local modules after Node imports.
|
|
42
|
+
|
|
43
|
+
Path Aliases:
|
|
44
|
+
|
|
45
|
+
- None detected. Imports use relative paths and package names. Keep using relative imports within `src/`.
|
|
46
|
+
|
|
47
|
+
## Error Handling
|
|
48
|
+
|
|
49
|
+
Patterns:
|
|
50
|
+
|
|
51
|
+
- Use try/catch around file system operations and external command execution; log errors with `console.error` (see `src/build/*.ts`, `src/utils/*`).
|
|
52
|
+
- Functions that perform operations return boolean success flags (`Promise<boolean>`) where appropriate (e.g., `src/build/build-prettier.ts`, `src/build/build-bundle.ts`).
|
|
53
|
+
|
|
54
|
+
## Logging
|
|
55
|
+
|
|
56
|
+
Framework: console
|
|
57
|
+
|
|
58
|
+
Patterns:
|
|
59
|
+
|
|
60
|
+
- Use `console.log` for informational messages, `console.warn` for warnings, `console.error` for errors. Follow existing use in `src/build/*` and `src/utils/*`.
|
|
61
|
+
|
|
62
|
+
## Comments
|
|
63
|
+
|
|
64
|
+
When to Comment:
|
|
65
|
+
|
|
66
|
+
- Use JSDoc/TSDoc comments for exported functions and modules. Code contains JSDoc-style function headers (e.g., `src/build/build-prettier.ts`).
|
|
67
|
+
|
|
68
|
+
JSDoc/TSDoc:
|
|
69
|
+
|
|
70
|
+
- Use TSDoc/JSDoc annotations for function parameters and return values on public utilities.
|
|
71
|
+
|
|
72
|
+
## Function Design
|
|
73
|
+
|
|
74
|
+
Size:
|
|
75
|
+
|
|
76
|
+
- Functions typically remain under ~200 lines and perform a single responsibility (e.g., `createShapeTemplate` orchestrates template copying and updates but delegates to small helpers).
|
|
77
|
+
|
|
78
|
+
Parameters:
|
|
79
|
+
|
|
80
|
+
- Prefer explicit parameters and typed signatures. Existing functions are strongly typed (see `tsconfig.json` with `strict: true`).
|
|
81
|
+
|
|
82
|
+
Return Values:
|
|
83
|
+
|
|
84
|
+
- Use typed return values (`Promise<void>`, `Promise<boolean>`) and avoid implicit `any`.
|
|
85
|
+
|
|
86
|
+
## Module Design
|
|
87
|
+
|
|
88
|
+
Exports:
|
|
89
|
+
|
|
90
|
+
- Modules export named functions (e.g., `export async function createShapeTemplate ...` in `src/create/shape/create-shape.ts`). Prefer named exports.
|
|
91
|
+
Barrel Files:
|
|
92
|
+
- Not used. Add explicit exports per-file instead of index barrel files unless a clear grouping is required.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
_Convention analysis: 2026-03-08_
|
|
@@ -1,3 +1,73 @@
|
|
|
1
|
-
External Integrations
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# External Integrations
|
|
2
|
+
|
|
3
|
+
**Analysis Date:** 2026-03-08
|
|
4
|
+
|
|
5
|
+
## APIs & External Services
|
|
6
|
+
|
|
7
|
+
No cloud SDKs (Stripe, AWS, Supabase, etc.) detected in `src/` imports. Searches for common providers returned no matches.
|
|
8
|
+
|
|
9
|
+
## Data Storage
|
|
10
|
+
|
|
11
|
+
**Databases:**
|
|
12
|
+
|
|
13
|
+
- Not detected. No database clients (pg/mysql/mongodb) are imported in `src/`.
|
|
14
|
+
|
|
15
|
+
**File Storage:**
|
|
16
|
+
|
|
17
|
+
- Local filesystem via `fs-extra` used throughout (`src/utils/file-utils.ts`, `src/utils/template-utils.ts`, `src/create/*`) to read/write project templates and package files.
|
|
18
|
+
|
|
19
|
+
**Caching:**
|
|
20
|
+
|
|
21
|
+
- None detected.
|
|
22
|
+
|
|
23
|
+
## Authentication & Identity
|
|
24
|
+
|
|
25
|
+
**Auth Provider:**
|
|
26
|
+
|
|
27
|
+
- Not applicable. This is a local CLI tool and does not integrate with external auth providers.
|
|
28
|
+
|
|
29
|
+
## Monitoring & Observability
|
|
30
|
+
|
|
31
|
+
**Error Tracking:**
|
|
32
|
+
|
|
33
|
+
- None detected (no Sentry / Datadog / Rollbar SDK imports).
|
|
34
|
+
|
|
35
|
+
**Logs:**
|
|
36
|
+
|
|
37
|
+
- Standard console logging (`console.log`, `console.error`, `console.warn`) used throughout build and template utilities (e.g., `src/build/*`, `src/utils/*`).
|
|
38
|
+
|
|
39
|
+
## CI/CD & Deployment
|
|
40
|
+
|
|
41
|
+
**Hosting:**
|
|
42
|
+
|
|
43
|
+
- NPM registry publishes defined in `.github/workflows/npm-publish.yml` (publishes on tags `v*`).
|
|
44
|
+
|
|
45
|
+
**CI Pipeline:**
|
|
46
|
+
|
|
47
|
+
- GitHub Actions workflows:
|
|
48
|
+
- `/.github/workflows/node.js-ci.yml` runs on push and pull_request for `main`, executes `pnpm install`, `pnpm run build:ci`, and `pnpm test`.
|
|
49
|
+
- `/.github/workflows/npm-publish.yml` publishes package on version tags using OIDC-based authentication.
|
|
50
|
+
|
|
51
|
+
## Environment Configuration
|
|
52
|
+
|
|
53
|
+
**Required env vars:**
|
|
54
|
+
|
|
55
|
+
- No application runtime env vars detected in source. CI workflows rely on GitHub OIDC and standard GitHub Actions environment variables.
|
|
56
|
+
|
|
57
|
+
**Secrets location:**
|
|
58
|
+
|
|
59
|
+
- No secrets files in repo. GitHub publishing uses built-in OIDC and repository permissions configured in the workflow (`id-token: write`).
|
|
60
|
+
|
|
61
|
+
## Webhooks & Callbacks
|
|
62
|
+
|
|
63
|
+
**Incoming:**
|
|
64
|
+
|
|
65
|
+
- None detected.
|
|
66
|
+
|
|
67
|
+
**Outgoing:**
|
|
68
|
+
|
|
69
|
+
- None detected.
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
_Integration audit: 2026-03-08_
|
|
@@ -1,11 +1,85 @@
|
|
|
1
|
-
|
|
1
|
+
# Technology Stack
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
- TypeScript (src/)
|
|
5
|
-
- Node.js for CLI
|
|
3
|
+
**Analysis Date:** 2026-03-08
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
- Vitest, tsc, pnpm
|
|
5
|
+
## Languages
|
|
9
6
|
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
**Primary:**
|
|
8
|
+
|
|
9
|
+
- TypeScript (>=5.x) - used across the entire codebase in `src/` (e.g. `src/cli.ts`, `src/create/*`, `src/build/*`)
|
|
10
|
+
|
|
11
|
+
**Secondary:**
|
|
12
|
+
|
|
13
|
+
- JavaScript (Node) - runtime JS emitted to `dist/` (package `type` set to `module` in `package.json`)
|
|
14
|
+
|
|
15
|
+
## Runtime
|
|
16
|
+
|
|
17
|
+
**Environment:**
|
|
18
|
+
|
|
19
|
+
- Node.js 24 (CI uses `actions/setup-node` with `node-version: "24"` in `.github/workflows/node.js-ci.yml`)
|
|
20
|
+
|
|
21
|
+
**Package Manager:**
|
|
22
|
+
|
|
23
|
+
- pnpm (declared in `package.json` via `packageManager`: `pnpm@10.31.0`)
|
|
24
|
+
- Lockfile present: `pnpm-lock.yaml`
|
|
25
|
+
|
|
26
|
+
## Frameworks
|
|
27
|
+
|
|
28
|
+
**Core:**
|
|
29
|
+
|
|
30
|
+
- None web-framework specific. This is a CLI application built with Node and TypeScript. Entry point: `src/cli.ts`.
|
|
31
|
+
|
|
32
|
+
**CLI/Command parsing:**
|
|
33
|
+
|
|
34
|
+
- `commander` (`src/cli.ts`, `src/create/create.ts`, `src/build/*`) - used to declare commands and subcommands.
|
|
35
|
+
|
|
36
|
+
**Testing:**
|
|
37
|
+
|
|
38
|
+
- `vitest` (configured in `vitest.config.ts`, tests in `tests/*.test.ts`)
|
|
39
|
+
|
|
40
|
+
**Build/Dev:**
|
|
41
|
+
|
|
42
|
+
- `typescript` for compilation (`tsc -p src`, see `package.json` scripts)
|
|
43
|
+
- `webpack` used by some build tasks (see `src/build/build-bundle.ts` importing `webpack`)
|
|
44
|
+
- `swc` (`@swc/core`) is listed as dependency (used by some tooling or downstream tasks)
|
|
45
|
+
|
|
46
|
+
## Key Dependencies
|
|
47
|
+
|
|
48
|
+
**Critical:**
|
|
49
|
+
|
|
50
|
+
- `commander` - command-line parsing (`src/cli.ts`)
|
|
51
|
+
- `fs-extra` - filesystem utilities used widely (`src/utils/*`, `src/create/*`, `src/build/*`)
|
|
52
|
+
- `prettier` - formatting (`src/build/build-prettier.ts`)
|
|
53
|
+
- `typescript` - language (dev dependency and build target)
|
|
54
|
+
|
|
55
|
+
**Infrastructure / Tooling:**
|
|
56
|
+
|
|
57
|
+
- `prompts` - interactive prompts for the `create` subcommands (`src/create/*`)
|
|
58
|
+
- `lookpath` - used to detect external commands (`src/utils/template-utils.ts`, `src/utils/file-utils.ts`)
|
|
59
|
+
- `webpack` - bundling (`src/build/build-bundle.ts`)
|
|
60
|
+
- `vitest` - testing runner (`tests/*.test.ts`, `vitest.config.ts`)
|
|
61
|
+
|
|
62
|
+
## Configuration
|
|
63
|
+
|
|
64
|
+
**Environment:**
|
|
65
|
+
|
|
66
|
+
- No `.env` usage detected. CI sets Node version and runs pnpm in GitHub workflows (`.github/workflows/*.yml`).
|
|
67
|
+
|
|
68
|
+
**Build:**
|
|
69
|
+
|
|
70
|
+
- TypeScript config: `tsconfig.json` (root) and `src/tsconfig.json` included via `eslint.config.js` (parserOptions.project).
|
|
71
|
+
- Build scripts are defined in `package.json` (e.g. `pnpm run build`, `pnpm run build:ci`, `pnpm run build:ts:cjs`)
|
|
72
|
+
|
|
73
|
+
## Platform Requirements
|
|
74
|
+
|
|
75
|
+
**Development:**
|
|
76
|
+
|
|
77
|
+
- Node.js 24+, pnpm (v10+), git - used by scripts and utilities (`src/utils/file-utils.ts` uses `git` if available)
|
|
78
|
+
|
|
79
|
+
**Production / Distribution:**
|
|
80
|
+
|
|
81
|
+
- Packaged as npm package (`publishConfig` in `package.json` and `npm-publish` workflow). Outputs are placed under `dist/` and CLI binary `dist/cli.js` (`bin` in `package.json`).
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
_Stack analysis: 2026-03-08_
|
|
@@ -1,3 +1,104 @@
|
|
|
1
|
-
Structure
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# Codebase Structure
|
|
2
|
+
|
|
3
|
+
**Analysis Date:** 2026-03-08
|
|
4
|
+
|
|
5
|
+
## Directory Layout
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
[project-root]/
|
|
9
|
+
├── src/ # TypeScript source for the CLI
|
|
10
|
+
│ ├── build/ # Build command implementations and helpers
|
|
11
|
+
│ ├── create/ # Create command implementations (preset, plugin, shape)
|
|
12
|
+
│ └── utils/ # Shared utilities (file, template, string helpers)
|
|
13
|
+
├── files/ # Template files used by create commands
|
|
14
|
+
├── tests/ # Vitest unit tests for utilities and create flows
|
|
15
|
+
├── dist/ # Build output (generated, should be ignored)
|
|
16
|
+
├── package.json # NPM package config and scripts
|
|
17
|
+
├── pnpm-lock.yaml # Lockfile for pnpm
|
|
18
|
+
├── tsconfig.json # TypeScript compiler options
|
|
19
|
+
└── .github/workflows/ # CI and publish workflows
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Directory Purposes
|
|
23
|
+
|
|
24
|
+
**`src/`**:
|
|
25
|
+
|
|
26
|
+
- Purpose: Primary implementation in TypeScript.
|
|
27
|
+
- Contains: `src/cli.ts`, `src/build/*`, `src/create/*`, `src/utils/*`.
|
|
28
|
+
- Key files: `src/cli.ts` (entry), `src/create/create.ts`, `src/build/build.ts`, `src/utils/file-utils.ts`.
|
|
29
|
+
|
|
30
|
+
**`files/`**:
|
|
31
|
+
|
|
32
|
+
- Purpose: Scaffolding templates used by the create commands.
|
|
33
|
+
- Contains: `files/create-shape`, `files/create-preset`, `files/create-plugin`, `files/empty-project`.
|
|
34
|
+
|
|
35
|
+
**`tests/`**:
|
|
36
|
+
|
|
37
|
+
- Purpose: Unit tests executed by `vitest`.
|
|
38
|
+
- Contains: tests validating template creation and utility behavior (e.g., `tests/create-shape.test.ts`, `tests/file-utils.test.ts`).
|
|
39
|
+
|
|
40
|
+
**`dist/`**:
|
|
41
|
+
|
|
42
|
+
- Purpose: Output of compilation/build process. Generated; not committed.
|
|
43
|
+
|
|
44
|
+
## Key File Locations
|
|
45
|
+
|
|
46
|
+
**Entry Points:**
|
|
47
|
+
|
|
48
|
+
- `src/cli.ts`: CLI program creation and command registration.
|
|
49
|
+
|
|
50
|
+
**Configuration:**
|
|
51
|
+
|
|
52
|
+
- `package.json`: scripts, dependencies, package metadata.
|
|
53
|
+
- `tsconfig.json`: TypeScript configuration.
|
|
54
|
+
- `vitest.config.ts`: Test runner configuration.
|
|
55
|
+
|
|
56
|
+
**Core Logic:**
|
|
57
|
+
|
|
58
|
+
- `src/utils/file-utils.ts`: token replacement, destination directory checks, git repository lookup.
|
|
59
|
+
- `src/utils/template-utils.ts`: template transformers, copy helpers, npm build/install invocations.
|
|
60
|
+
|
|
61
|
+
**Commands:**
|
|
62
|
+
|
|
63
|
+
- `src/create/*`: `src/create/create.ts`, `src/create/preset/*`, `src/create/plugin/*`, `src/create/shape/*`.
|
|
64
|
+
- `src/build/*`: `build.ts`, `build-prettier.ts`, `build-bundle.ts`, `build-tsc.ts`, `build-eslint.ts`, `build-distfiles.ts`, `build-diststats.ts`.
|
|
65
|
+
|
|
66
|
+
## Naming Conventions
|
|
67
|
+
|
|
68
|
+
Files:
|
|
69
|
+
|
|
70
|
+
- Kebab-case for templates/files under `files/`.
|
|
71
|
+
- Source files in `src/` use `camelCase` or `kebab-case` depending on purpose; commands grouped into directories named by feature.
|
|
72
|
+
|
|
73
|
+
Directories:
|
|
74
|
+
|
|
75
|
+
- Feature directories under `src/` (e.g., `create`, `build`, `utils`).
|
|
76
|
+
|
|
77
|
+
## Where to Add New Code
|
|
78
|
+
|
|
79
|
+
New Feature (command):
|
|
80
|
+
New Component/Module:
|
|
81
|
+
|
|
82
|
+
- Implementation: `src/utils/` for shared helpers, or `src/<feature>/` if feature-specific.
|
|
83
|
+
- Export public helpers from their files; avoid adding global side-effects.
|
|
84
|
+
|
|
85
|
+
Utilities:
|
|
86
|
+
|
|
87
|
+
- Shared helpers: `src/utils/`.
|
|
88
|
+
- If utility is generic, add tests in `tests/` and export clearly-typed interfaces.
|
|
89
|
+
|
|
90
|
+
## Special Directories
|
|
91
|
+
|
|
92
|
+
`files/`:
|
|
93
|
+
|
|
94
|
+
- Purpose: Template assets for project scaffolding.
|
|
95
|
+
- Generated: No
|
|
96
|
+
- Committed: Yes
|
|
97
|
+
|
|
98
|
+
`tests/`:
|
|
99
|
+
|
|
100
|
+
- Purpose: Contains unit tests. Committed: Yes
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
_Structure analysis: 2026-03-08_
|