@xylabs/ts-scripts-yarn3 7.4.20 → 7.4.22
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/dist/actions/claude-clean.mjs +71 -0
- package/dist/actions/claude-clean.mjs.map +1 -0
- package/dist/actions/claude-commands.mjs +11 -2
- package/dist/actions/claude-commands.mjs.map +1 -1
- package/dist/actions/claude-rules.mjs +27 -7
- package/dist/actions/claude-rules.mjs.map +1 -1
- package/dist/actions/claude-skills.mjs.map +1 -1
- package/dist/actions/dupdeps.mjs +3 -2
- package/dist/actions/dupdeps.mjs.map +1 -1
- package/dist/actions/gitignore.mjs +152 -0
- package/dist/actions/gitignore.mjs.map +1 -0
- package/dist/actions/index.mjs +392 -206
- package/dist/actions/index.mjs.map +1 -1
- package/dist/bin/xy.mjs +432 -226
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.d.ts +11 -3
- package/dist/index.mjs +495 -282
- package/dist/index.mjs.map +1 -1
- package/dist/lib/claudeMdTemplate.mjs +5 -1
- package/dist/lib/claudeMdTemplate.mjs.map +1 -1
- package/dist/lib/gitignoreTemplate.mjs +12 -0
- package/dist/lib/gitignoreTemplate.mjs.map +1 -0
- package/dist/lib/index.mjs +17 -3
- package/dist/lib/index.mjs.map +1 -1
- package/dist/xy/build/buildCommand.mjs +161 -0
- package/dist/xy/build/buildCommand.mjs.map +1 -0
- package/dist/xy/build/compileCommand.mjs +174 -0
- package/dist/xy/build/compileCommand.mjs.map +1 -0
- package/dist/xy/build/compileOnlyCommand.mjs +175 -0
- package/dist/xy/build/compileOnlyCommand.mjs.map +1 -0
- package/dist/xy/build/copyAssetsCommand.mjs +84 -0
- package/dist/xy/build/copyAssetsCommand.mjs.map +1 -0
- package/dist/xy/{build-commands → build}/index.mjs +45 -40
- package/dist/xy/build/index.mjs.map +1 -0
- package/dist/xy/build/rebuildCommand.mjs +114 -0
- package/dist/xy/build/rebuildCommand.mjs.map +1 -0
- package/dist/xy/build/recompileCommand.mjs +204 -0
- package/dist/xy/build/recompileCommand.mjs.map +1 -0
- package/dist/xy/common/claude/cleanCommand.mjs +79 -0
- package/dist/xy/common/claude/cleanCommand.mjs.map +1 -0
- package/dist/xy/common/claude/commandsCommand.mjs +11 -2
- package/dist/xy/common/claude/commandsCommand.mjs.map +1 -1
- package/dist/xy/common/claude/index.mjs +171 -69
- package/dist/xy/common/claude/index.mjs.map +1 -1
- package/dist/xy/common/claude/initCommand.mjs +38 -115
- package/dist/xy/common/claude/initCommand.mjs.map +1 -1
- package/dist/xy/common/claude/rulesCommand.mjs +27 -7
- package/dist/xy/common/claude/rulesCommand.mjs.map +1 -1
- package/dist/xy/common/claude/skillsCommand.mjs.map +1 -1
- package/dist/xy/common/gitignoreCommand.mjs +158 -0
- package/dist/xy/common/gitignoreCommand.mjs.map +1 -0
- package/dist/xy/common/index.mjs +304 -109
- package/dist/xy/common/index.mjs.map +1 -1
- package/dist/xy/index.mjs +432 -226
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/install/dupdepsCommand.mjs +3 -2
- package/dist/xy/install/dupdepsCommand.mjs.map +1 -1
- package/dist/xy/install/index.mjs +3 -2
- package/dist/xy/install/index.mjs.map +1 -1
- package/dist/xy/xy.mjs +432 -226
- package/dist/xy/xy.mjs.map +1 -1
- package/package.json +2 -2
- package/templates/claude/CLAUDE-local.md +4 -0
- package/templates/claude/commands/xy-dead.md +5 -0
- package/templates/claude/{rules/xylabs-dependencies.md → commands/xy-deps.md} +7 -7
- package/templates/claude/commands/xy-dupdeps.md +5 -0
- package/templates/claude/commands/xy-gen-docs.md +5 -0
- package/templates/claude/commands/xy-gitignore.md +5 -0
- package/templates/claude/commands/xy-gitlint.md +5 -0
- package/templates/claude/commands/xy-license.md +5 -0
- package/templates/claude/commands/xy-lint-rules.md +44 -0
- package/templates/claude/commands/xy-recompile.md +5 -0
- package/templates/claude/commands/xy-reinstall.md +5 -0
- package/templates/claude/commands/xy-relint.md +5 -0
- package/templates/claude/commands/xy-retest.md +5 -0
- package/templates/claude/commands/xy-sonar.md +5 -0
- package/templates/claude/commands/xy-up.md +7 -0
- package/templates/claude/rules/xylabs-architecture.md +4 -7
- package/templates/claude/rules/xylabs-build.md +6 -11
- package/templates/claude/rules/xylabs-git-workflow.md +3 -5
- package/templates/claude/rules/xylabs-naming.md +4 -7
- package/templates/claude/rules/xylabs-style.md +14 -19
- package/templates/claude/skills/xylabs-e2e-setup/SKILL.md +16 -2
- package/templates/gitignore/template.gitignore +40 -0
- package/dist/actions/gitignore-gen.mjs +0 -88
- package/dist/actions/gitignore-gen.mjs.map +0 -1
- package/dist/xy/build-commands/build.mjs +0 -502
- package/dist/xy/build-commands/build.mjs.map +0 -1
- package/dist/xy/build-commands/index.mjs.map +0 -1
- package/dist/xy/common/gitignoreGenCommand.mjs +0 -98
- package/dist/xy/common/gitignoreGenCommand.mjs.map +0 -1
- package/templates/claude/commands/xylabs-deploy-major.md +0 -7
- package/templates/claude/commands/xylabs-deploy-minor.md +0 -7
- package/templates/claude/commands/xylabs-deploy.md +0 -7
- package/templates/claude/rules/xylabs-error-handling.md +0 -7
- package/templates/claude/rules/xylabs-frameworks.md +0 -8
- package/templates/claude/rules/xylabs-linting.md +0 -55
- package/templates/claude/rules/xylabs-typescript.md +0 -11
- /package/templates/claude/commands/{xylabs-build.md → xy-build.md} +0 -0
- /package/templates/claude/commands/{xylabs-clean.md → xy-clean.md} +0 -0
- /package/templates/claude/commands/{xylabs-compile.md → xy-compile.md} +0 -0
- /package/templates/claude/commands/{xylabs-cycle.md → xy-cycle.md} +0 -0
- /package/templates/claude/commands/{xylabs-deplint.md → xy-deplint.md} +0 -0
- /package/templates/claude/commands/{xylabs-fix.md → xy-fix.md} +0 -0
- /package/templates/claude/commands/{xylabs-knip.md → xy-knip.md} +0 -0
- /package/templates/claude/commands/{xylabs-lint.md → xy-lint.md} +0 -0
- /package/templates/claude/commands/{xylabs-publint.md → xy-publint.md} +0 -0
- /package/templates/claude/commands/{xylabs-rebuild.md → xy-rebuild.md} +0 -0
- /package/templates/claude/commands/{xylabs-test.md → xy-test.md} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xylabs/ts-scripts-yarn3",
|
|
3
|
-
"version": "7.4.
|
|
3
|
+
"version": "7.4.22",
|
|
4
4
|
"description": "TypeScript project scripts",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"xylabs",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"@types/parse-git-config": "~3.0.4",
|
|
94
94
|
"@types/picomatch": "~4.0.2",
|
|
95
95
|
"@types/yargs": "~17.0.35",
|
|
96
|
-
"@xylabs/tsconfig": "~7.4.
|
|
96
|
+
"@xylabs/tsconfig": "~7.4.22",
|
|
97
97
|
"esbuild": "0.27.3",
|
|
98
98
|
"types-package-json": "~2.0.39",
|
|
99
99
|
"typescript": "~5.9.3",
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
> Auto-managed by `yarn xy claude-rules`. Do not edit manually.
|
|
4
|
-
|
|
5
|
-
When a dependency is needed, prefer these packages:
|
|
1
|
+
Reference for preferred dependencies in XY Labs projects. Consult this when adding a new dependency.
|
|
6
2
|
|
|
7
3
|
| Purpose | Package |
|
|
8
4
|
|---|---|
|
|
@@ -14,11 +10,15 @@ When a dependency is needed, prefer these packages:
|
|
|
14
10
|
| Lodash replacements | `@xylabs/lodash` |
|
|
15
11
|
| React state | React hooks + context (avoid Redux) |
|
|
16
12
|
| React UI components | `@mui/material` (Material UI) |
|
|
17
|
-
| Styling | MUI `sx` prop and `styled()`
|
|
13
|
+
| Styling | MUI `sx` prop and `styled()` — no CSS-in-JS libraries or raw CSS |
|
|
18
14
|
| Testing | `vitest` |
|
|
19
15
|
| Bundling | `tsup` (libraries), `webpack` (apps) |
|
|
20
|
-
| Linting | `eslint` with `@xylabs/eslint-config` |
|
|
16
|
+
| Linting | `eslint` with `@xylabs/eslint-config-flat` |
|
|
21
17
|
| Shared XY Labs utilities | `@xylabs/sdk-js` |
|
|
22
18
|
| XYO application code | `@xyo-network/sdk-js` |
|
|
23
19
|
| XYO Layer 1 Protocol | `@xyo-network/xl1-sdk` |
|
|
24
20
|
| XYO Layer 1 Chain | `@xyo-network/chain-sdk` |
|
|
21
|
+
|
|
22
|
+
**Notes:**
|
|
23
|
+
- `zod` must be a `peerDependency`, never a direct `dependency`
|
|
24
|
+
- `sideEffects: false` required on every published package
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
Reference for non-obvious ESLint rules enforced by `@xylabs/eslint-config-flat`. Consult this before writing code to avoid common violations.
|
|
2
|
+
|
|
3
|
+
## Complexity limits
|
|
4
|
+
- `max-statements: 32` — break large functions into smaller helpers
|
|
5
|
+
- `complexity: 18` — max cyclomatic complexity per function
|
|
6
|
+
- `max-lines: 512` — per file (blank lines excluded)
|
|
7
|
+
- `max-depth: 6` — max nesting depth
|
|
8
|
+
|
|
9
|
+
## Import style
|
|
10
|
+
- `unicorn/import-style` — default imports for Node built-ins: `import PATH from 'node:path'`
|
|
11
|
+
- `no-restricted-imports` — never import from barrel `index.ts` files
|
|
12
|
+
|
|
13
|
+
## Object formatting
|
|
14
|
+
- Objects/imports/destructuring with 3+ properties must use multi-line:
|
|
15
|
+
```typescript
|
|
16
|
+
// wrong
|
|
17
|
+
const { created, templateNames, updated } = syncRuleFiles(rulesDir)
|
|
18
|
+
|
|
19
|
+
// correct
|
|
20
|
+
const {
|
|
21
|
+
created, templateNames, updated,
|
|
22
|
+
} = syncRuleFiles(rulesDir)
|
|
23
|
+
```
|
|
24
|
+
- Always use spaces inside braces: `{ foo }` not `{foo}`
|
|
25
|
+
|
|
26
|
+
## Expressions
|
|
27
|
+
- No standalone ternaries as statements — use `if/else`
|
|
28
|
+
- Prefix unused variables with `_`
|
|
29
|
+
|
|
30
|
+
## Enums are disallowed
|
|
31
|
+
- Use string literal unions or `const` objects:
|
|
32
|
+
```typescript
|
|
33
|
+
// wrong
|
|
34
|
+
enum Status { Active, Inactive }
|
|
35
|
+
|
|
36
|
+
// correct
|
|
37
|
+
type Status = 'active' | 'inactive'
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Class member ordering
|
|
41
|
+
- Order: fields, constructor, accessors, methods (alphabetical within groups)
|
|
42
|
+
|
|
43
|
+
## JSX
|
|
44
|
+
- No unnecessary braces in props: `prop="value"` not `prop={"value"}`
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
# XY Labs - Architecture
|
|
1
|
+
# XY Labs - Architecture
|
|
2
2
|
|
|
3
3
|
> Auto-managed by `yarn xy claude-rules`. Do not edit manually.
|
|
4
4
|
|
|
5
|
-
-
|
|
5
|
+
- Yarn workspaces monorepo; all packages share a single version
|
|
6
6
|
- Each package compiles to ESM via `tsup` (output to `dist/`)
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
- Follow the dependency inversion principle - depend on abstractions, not concretions
|
|
10
|
-
- Prefer composition over inheritance
|
|
11
|
-
- Keep packages small and focused on a single responsibility
|
|
7
|
+
- Prefer composition over inheritance; depend on abstractions
|
|
8
|
+
- Vitest for testing; React + MUI for frontend; Express for backend
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
# XY Labs - Build
|
|
1
|
+
# XY Labs - Build
|
|
2
2
|
|
|
3
3
|
> Auto-managed by `yarn xy claude-rules`. Do not edit manually.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
yarn xy
|
|
7
|
-
yarn xy
|
|
8
|
-
yarn xy
|
|
9
|
-
|
|
10
|
-
yarn xy deplint # Check dependency declarations
|
|
11
|
-
yarn xy fix # Auto-fix lint issues
|
|
12
|
-
yarn xy cycle # Check for circular dependencies
|
|
13
|
-
yarn xy publint # Check package.json files for correctness
|
|
14
|
-
```
|
|
5
|
+
- Run all `yarn xy` commands from the repo root, never from inside a package directory
|
|
6
|
+
- Single-package: `yarn xy lint <package-name>` (use the name from package.json, not the path)
|
|
7
|
+
- Run `yarn xy lint` after significant changes to verify compliance
|
|
8
|
+
- Run `yarn xy build` before pushing
|
|
9
|
+
- Never edit package version fields manually — use `yarn xy deploy`
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
# XY Labs - Git
|
|
1
|
+
# XY Labs - Git
|
|
2
2
|
|
|
3
3
|
> Auto-managed by `yarn xy claude-rules`. Do not edit manually.
|
|
4
4
|
|
|
5
|
-
-
|
|
6
|
-
-
|
|
5
|
+
- Conventional commits: `feat:`, `fix:`, `chore:`, `refactor:`
|
|
6
|
+
- Atomic commits — one logical change per commit
|
|
7
7
|
- Never force-push to shared branches
|
|
8
|
-
- Use `yarn xy deploy`, `yarn xy deploy-minor`, or `yarn xy deploy-major` for versioning
|
|
9
|
-
- Run `yarn xy build` before pushing to verify the build passes
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
# XY Labs - Naming
|
|
1
|
+
# XY Labs - Naming
|
|
2
2
|
|
|
3
3
|
> Auto-managed by `yarn xy claude-rules`. Do not edit manually.
|
|
4
4
|
|
|
5
|
-
- Files: camelCase for modules
|
|
6
|
-
- Variables/functions: camelCase
|
|
7
|
-
-
|
|
8
|
-
- Constants: UPPER_SNAKE_CASE (e.g. `MAX_RETRIES`, `DEFAULT_TIMEOUT`)
|
|
9
|
-
- Boolean variables: prefix with `is`, `has`, `should`, `can` (e.g. `isReady`, `hasError`)
|
|
10
|
-
- Event handlers: prefix with `on` (e.g. `onClick`, `onSubmit`)
|
|
5
|
+
- Files: camelCase for modules, PascalCase for components/classes
|
|
6
|
+
- Variables/functions: camelCase; Classes/interfaces/types: PascalCase
|
|
7
|
+
- Constants: UPPER_SNAKE_CASE; Booleans: `is`/`has`/`should`/`can` prefix
|
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
# XY Labs - Style
|
|
1
|
+
# XY Labs - Code Style
|
|
2
2
|
|
|
3
3
|
> Auto-managed by `yarn xy claude-rules`. Do not edit manually.
|
|
4
4
|
|
|
5
|
-
-
|
|
6
|
-
-
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
- Use default imports for Node.js built-in modules: `import PATH from 'node:path'`, `import FS from 'node:fs'` — not named imports like `import { resolve } from 'node:path'` (enforced by `unicorn/import-style`)
|
|
19
|
-
- String quotes: single quotes for code, backticks for interpolation
|
|
20
|
-
- Trailing commas: always (ES5+)
|
|
21
|
-
- Semicolons: never (rely on ASI)
|
|
22
|
-
- Indent with 2 spaces
|
|
5
|
+
- ESM only — no CommonJS (`require`/`module.exports`)
|
|
6
|
+
- No semicolons, single quotes, trailing commas, 2-space indent
|
|
7
|
+
- `const` over `let`; never `var`
|
|
8
|
+
- `function` declarations for top-level; arrows only for callbacks/closures
|
|
9
|
+
- Explicit return types on exported functions
|
|
10
|
+
- `interface` over `type` for object shapes; named exports over default exports
|
|
11
|
+
- Default imports for Node built-ins: `import PATH from 'node:path'` (not named imports)
|
|
12
|
+
- No `enum` — use string literal unions or `const` objects
|
|
13
|
+
- No `any` — use `unknown`; avoid `as`, prefer type guards
|
|
14
|
+
- No `import * as X`; no importing from barrel `index.ts` files
|
|
15
|
+
- Prefix unused variables with `_`
|
|
16
|
+
- Objects/imports/destructuring with 3+ properties must use multi-line formatting
|
|
17
|
+
- When a function uses `await`, return `Promise<T>` — never `Promise<Promisable<T>>`
|
|
@@ -180,13 +180,27 @@ into `packages/e2e`. Use the e2e package name you derived in Step 1.
|
|
|
180
180
|
```
|
|
181
181
|
Only add scripts that don't already exist.
|
|
182
182
|
---
|
|
183
|
-
## Step 4 — Install Playwright browsers
|
|
184
|
-
After scaffolding,
|
|
183
|
+
## Step 4 — Install Playwright browsers and CLI tool
|
|
184
|
+
After scaffolding, run the following two commands via the Bash tool:
|
|
185
|
+
|
|
186
|
+
**4a — Install browser binaries:**
|
|
185
187
|
```bash
|
|
186
188
|
yarn workspace <derived-e2e-name> playwright install
|
|
187
189
|
```
|
|
188
190
|
This downloads the Chromium, Firefox, and WebKit browser binaries. Without this step the tests
|
|
189
191
|
will fail immediately with a "browser not found" error.
|
|
192
|
+
|
|
193
|
+
**4b — Install the `@playwright/cli` package and its skills:**
|
|
194
|
+
```bash
|
|
195
|
+
yarn workspace <derived-e2e-name> add @playwright/cli@latest && yarn workspace <derived-e2e-name> playwright-cli install --skills
|
|
196
|
+
```
|
|
197
|
+
`@playwright/cli` provides the `playwright-cli` binary. Running `playwright-cli install --skills`
|
|
198
|
+
installs the Playwright VS Code agent skills into the workspace so Copilot and other AI tooling
|
|
199
|
+
can generate accurate Playwright tests against the actual page structure.
|
|
200
|
+
|
|
201
|
+
Do not skip either step or ask the user to run them manually — execute both directly as part of
|
|
202
|
+
the setup.
|
|
203
|
+
|
|
190
204
|
---
|
|
191
205
|
## Conventions to preserve
|
|
192
206
|
- All files use ESM (`import`/`export`), never CommonJS.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Build outputs (root)
|
|
2
|
+
/build
|
|
3
|
+
/dist
|
|
4
|
+
/docs
|
|
5
|
+
|
|
6
|
+
# Build outputs (packages)
|
|
7
|
+
packages/*/build
|
|
8
|
+
packages/*/dist
|
|
9
|
+
packages/*/docs
|
|
10
|
+
|
|
11
|
+
# TypeScript
|
|
12
|
+
*.tsbuildinfo
|
|
13
|
+
|
|
14
|
+
# Logs
|
|
15
|
+
*.log
|
|
16
|
+
|
|
17
|
+
# OS
|
|
18
|
+
.DS_Store
|
|
19
|
+
|
|
20
|
+
# Node
|
|
21
|
+
node_modules
|
|
22
|
+
|
|
23
|
+
# Yarn
|
|
24
|
+
.pnp.*
|
|
25
|
+
.yarn/*
|
|
26
|
+
!.yarn/patches
|
|
27
|
+
!.yarn/plugins
|
|
28
|
+
!.yarn/releases
|
|
29
|
+
!.yarn/sdks
|
|
30
|
+
!.yarn/versions
|
|
31
|
+
|
|
32
|
+
# Lint
|
|
33
|
+
.eslintcache
|
|
34
|
+
|
|
35
|
+
# Claude Code
|
|
36
|
+
.claude
|
|
37
|
+
CLAUDE.local.md
|
|
38
|
+
|
|
39
|
+
# Claude Code worktrees
|
|
40
|
+
.claude-worktrees
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
// src/lib/file/constants.ts
|
|
2
|
-
var WINDOWS_NEWLINE_REGEX = /\r\n/g;
|
|
3
|
-
var CROSS_PLATFORM_NEWLINE = "\n";
|
|
4
|
-
|
|
5
|
-
// src/lib/file/fileLines.ts
|
|
6
|
-
import {
|
|
7
|
-
existsSync,
|
|
8
|
-
readFileSync,
|
|
9
|
-
writeFileSync
|
|
10
|
-
} from "fs";
|
|
11
|
-
|
|
12
|
-
// src/lib/string/empty.ts
|
|
13
|
-
var empty = (value) => value?.trim().length === 0;
|
|
14
|
-
var notEmpty = (value) => !empty(value);
|
|
15
|
-
|
|
16
|
-
// src/lib/string/union.ts
|
|
17
|
-
var union = (a, b) => /* @__PURE__ */ new Set([...new Set(a), ...new Set(b)]);
|
|
18
|
-
|
|
19
|
-
// src/lib/file/ReadFileSyncOptions.ts
|
|
20
|
-
var defaultReadFileSyncOptions = { encoding: "utf8" };
|
|
21
|
-
|
|
22
|
-
// src/lib/file/fileLines.ts
|
|
23
|
-
var readLines = (uri, options = defaultReadFileSyncOptions) => existsSync(uri) ? readFileSync(uri, options).replace(WINDOWS_NEWLINE_REGEX, CROSS_PLATFORM_NEWLINE).split(CROSS_PLATFORM_NEWLINE) : [];
|
|
24
|
-
var readNonEmptyLines = (uri, options = defaultReadFileSyncOptions) => readLines(uri, options).filter(notEmpty);
|
|
25
|
-
var writeLines = (uri, lines, options = defaultReadFileSyncOptions) => {
|
|
26
|
-
const existing = existsSync(uri) ? readFileSync(uri, options) : void 0;
|
|
27
|
-
const desired = lines.join(CROSS_PLATFORM_NEWLINE);
|
|
28
|
-
if (existing !== desired) writeFileSync(uri, desired, options);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
// src/lib/generateIgnoreFiles.ts
|
|
32
|
-
import chalk from "chalk";
|
|
33
|
-
|
|
34
|
-
// src/lib/yarn/workspace/yarnWorkspaces.ts
|
|
35
|
-
import { spawnSync } from "child_process";
|
|
36
|
-
var yarnWorkspaces = () => {
|
|
37
|
-
const result = spawnSync("yarn", ["workspaces", "list", "--json", "--recursive"], { encoding: "utf8", shell: true });
|
|
38
|
-
if (result.error) {
|
|
39
|
-
throw result.error;
|
|
40
|
-
}
|
|
41
|
-
return result.stdout.toString().split("\n").slice(0, -1).map((item) => {
|
|
42
|
-
return JSON.parse(item);
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
// src/lib/yarn/workspace/yarnWorkspace.ts
|
|
47
|
-
var yarnWorkspace = (pkg) => {
|
|
48
|
-
const workspace = yarnWorkspaces().find(({ name }) => name === pkg);
|
|
49
|
-
if (!workspace) throw new Error(`Workspace ${pkg} not found`);
|
|
50
|
-
return workspace;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
// src/lib/yarn/yarnInitCwd.ts
|
|
54
|
-
var INIT_CWD = () => {
|
|
55
|
-
if (!process.env.INIT_CWD) console.error("Missing INIT_CWD");
|
|
56
|
-
return process.env.INIT_CWD;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
// src/lib/generateIgnoreFiles.ts
|
|
60
|
-
var localeCompare = (a, b) => a.localeCompare(b);
|
|
61
|
-
var mergeEntries = (a, b) => [...union(a, b)].toSorted(localeCompare);
|
|
62
|
-
var generateIgnoreFiles = (filename2, pkg) => {
|
|
63
|
-
console.log(chalk.green(`Generate ${filename2} Files`));
|
|
64
|
-
const cwd = INIT_CWD() ?? ".";
|
|
65
|
-
const workspaces = pkg ? [yarnWorkspace(pkg)] : yarnWorkspaces();
|
|
66
|
-
const readEntries = (location) => readNonEmptyLines(`${location}/${filename2}`);
|
|
67
|
-
const writeEntries = (location, entries) => writeLines(`${location}/${filename2}`, entries);
|
|
68
|
-
const results = workspaces.map(({ location, name }) => {
|
|
69
|
-
try {
|
|
70
|
-
writeEntries(location, mergeEntries(readEntries(cwd), readEntries(location)));
|
|
71
|
-
return 0;
|
|
72
|
-
} catch (ex) {
|
|
73
|
-
const error = ex;
|
|
74
|
-
console.error(`Generate ${filename2} Files [${name}] [${error.message}]`);
|
|
75
|
-
return 1;
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
const succeeded = results.every((result) => result === 0);
|
|
79
|
-
return succeeded ? 0 : 1;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
// src/actions/gitignore-gen.ts
|
|
83
|
-
var filename = ".gitignore";
|
|
84
|
-
var gitignoreGen = (pkg) => generateIgnoreFiles(filename, pkg);
|
|
85
|
-
export {
|
|
86
|
-
gitignoreGen
|
|
87
|
-
};
|
|
88
|
-
//# sourceMappingURL=gitignore-gen.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/file/constants.ts","../../src/lib/file/fileLines.ts","../../src/lib/string/empty.ts","../../src/lib/string/union.ts","../../src/lib/file/ReadFileSyncOptions.ts","../../src/lib/generateIgnoreFiles.ts","../../src/lib/yarn/workspace/yarnWorkspaces.ts","../../src/lib/yarn/workspace/yarnWorkspace.ts","../../src/lib/yarn/yarnInitCwd.ts","../../src/actions/gitignore-gen.ts"],"sourcesContent":["export const WINDOWS_NEWLINE_REGEX = /\\r\\n/g\nexport const CROSS_PLATFORM_NEWLINE = '\\n'\n","import type { PathLike, WriteFileOptions } from 'node:fs'\nimport {\n existsSync, readFileSync,\n writeFileSync,\n} from 'node:fs'\n\nimport { notEmpty } from '../string/index.ts'\nimport { CROSS_PLATFORM_NEWLINE, WINDOWS_NEWLINE_REGEX } from './constants.ts'\nimport type { ReadFileSyncOptions } from './ReadFileSyncOptions.ts'\nimport { defaultReadFileSyncOptions } from './ReadFileSyncOptions.ts'\n\nexport const readLines = (uri: PathLike, options: ReadFileSyncOptions = defaultReadFileSyncOptions): string[] =>\n existsSync(uri)\n ? readFileSync(uri, options).replace(WINDOWS_NEWLINE_REGEX, CROSS_PLATFORM_NEWLINE).split(CROSS_PLATFORM_NEWLINE)\n : []\n\nexport const readNonEmptyLines = (uri: PathLike, options: ReadFileSyncOptions = defaultReadFileSyncOptions): string[] =>\n readLines(uri, options).filter(notEmpty)\n\nexport const writeLines = (uri: PathLike, lines: string[], options: WriteFileOptions = defaultReadFileSyncOptions) => {\n const existing = existsSync(uri) ? readFileSync(uri, options) : undefined\n const desired = lines.join(CROSS_PLATFORM_NEWLINE)\n // Check if the file is different before writing\n if (existing !== desired) writeFileSync(uri, desired, options)\n}\n","export const empty = (value?: string | undefined): boolean => value?.trim().length === 0\nexport const notEmpty = (value?: string | undefined): boolean => !empty(value)\n","export const union = (a: string[], b: string[]): Set<string> => new Set([...new Set(a), ...new Set(b)])\n","export type ReadFileSyncOptions = BufferEncoding | {\n encoding: BufferEncoding\n flags?: string\n}\n\nexport const defaultReadFileSyncOptions: ReadFileSyncOptions = { encoding: 'utf8' }\n","import chalk from 'chalk'\n\nimport { readNonEmptyLines, writeLines } from './file/index.ts'\nimport { union } from './string/index.ts'\nimport {\n INIT_CWD, yarnWorkspace, yarnWorkspaces,\n} from './yarn/index.ts'\n\nconst localeCompare = (a: string, b: string) => a.localeCompare(b)\n\nconst mergeEntries = (a: string[], b: string[]): string[] => [...union(a, b)].toSorted(localeCompare)\n\nexport const generateIgnoreFiles = (filename: string, pkg?: string) => {\n console.log(chalk.green(`Generate ${filename} Files`))\n const cwd = INIT_CWD() ?? '.'\n const workspaces = pkg ? [yarnWorkspace(pkg)] : yarnWorkspaces()\n const readEntries = (location: string): string[] => readNonEmptyLines(`${location}/${filename}`)\n const writeEntries = (location: string, entries: string[]) => writeLines(`${location}/${filename}`, entries)\n const results = workspaces.map(({ location, name }) => {\n try {\n writeEntries(location, mergeEntries(readEntries(cwd), readEntries(location)))\n return 0\n } catch (ex) {\n const error = ex as Error\n console.error(`Generate ${filename} Files [${name}] [${error.message}]`)\n return 1\n }\n })\n const succeeded = results.every(result => result === 0)\n return succeeded ? 0 : 1\n}\n","import { spawnSync } from 'node:child_process'\n\nimport type { Workspace } from './Workspace.ts'\n\nexport const yarnWorkspaces = (): Workspace[] => {\n const result = spawnSync('yarn', ['workspaces', 'list', '--json', '--recursive'], { encoding: 'utf8', shell: true })\n if (result.error) {\n throw result.error\n }\n return (\n result.stdout\n .toString()\n // NOTE: This probably doesn't work on Windows\n // TODO: Replace /r/n with /n first\n .split('\\n')\n .slice(0, -1)\n .map((item) => {\n return JSON.parse(item)\n })\n )\n}\n","import type { Workspace } from './Workspace.ts'\nimport { yarnWorkspaces } from './yarnWorkspaces.ts'\n\nexport const yarnWorkspace = (pkg: string): Workspace => {\n const workspace = yarnWorkspaces().find(({ name }) => name === pkg)\n if (!workspace) throw new Error(`Workspace ${pkg} not found`)\n return workspace\n}\n","export const INIT_CWD = () => {\n if (!process.env.INIT_CWD) console.error('Missing INIT_CWD')\n return process.env.INIT_CWD\n}\n","import { generateIgnoreFiles } from '../lib/index.ts'\n\nconst filename = '.gitignore'\n\nexport const gitignoreGen = (pkg?: string) => generateIgnoreFiles(filename, pkg)\n"],"mappings":";AAAO,IAAM,wBAAwB;AAC9B,IAAM,yBAAyB;;;ACAtC;AAAA,EACE;AAAA,EAAY;AAAA,EACZ;AAAA,OACK;;;ACJA,IAAM,QAAQ,CAAC,UAAwC,OAAO,KAAK,EAAE,WAAW;AAChF,IAAM,WAAW,CAAC,UAAwC,CAAC,MAAM,KAAK;;;ACDtE,IAAM,QAAQ,CAAC,GAAa,MAA6B,oBAAI,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC;;;ACK/F,IAAM,6BAAkD,EAAE,UAAU,OAAO;;;AHM3E,IAAM,YAAY,CAAC,KAAe,UAA+B,+BACtE,WAAW,GAAG,IACV,aAAa,KAAK,OAAO,EAAE,QAAQ,uBAA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