@space-arch/nx-plugin-std 1.7.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/README.md +35 -0
- package/dist/generators/cfg/cfg-generator.d.ts +5 -0
- package/dist/generators/cfg/cfg-generator.d.ts.map +1 -0
- package/dist/generators/cfg/cfg-generator.js +21 -0
- package/dist/generators/cfg/files/cursor-rules/commit-rules.mdc.template +274 -0
- package/dist/generators/cfg/files/cursor-rules/core-rules.mdc.template +106 -0
- package/dist/generators/cfg/files/cursor-rules/drizzle-orm-rules.mdc.template +110 -0
- package/dist/generators/cfg/files/cursor-rules/rust-rules.mdc.template +65 -0
- package/dist/generators/cfg/files/cursor-rules/typescript-rules.mdc.template +73 -0
- package/dist/generators/cfg/files/lint/.prettierignore.template +7 -0
- package/dist/generators/cfg/files/lint/.prettierrc.template +32 -0
- package/dist/generators/cfg/files/lint/eslint.config.mjs.template +91 -0
- package/dist/generators/cfg/lib/initCursorRules.d.ts +3 -0
- package/dist/generators/cfg/lib/initCursorRules.d.ts.map +1 -0
- package/dist/generators/cfg/lib/initCursorRules.js +4 -0
- package/dist/generators/cfg/lib/initEslintAndPrettierConfigs.d.ts +3 -0
- package/dist/generators/cfg/lib/initEslintAndPrettierConfigs.d.ts.map +1 -0
- package/dist/generators/cfg/lib/initEslintAndPrettierConfigs.js +21 -0
- package/dist/generators/cfg/lib/versionMatch.d.ts +3 -0
- package/dist/generators/cfg/lib/versionMatch.d.ts.map +1 -0
- package/dist/generators/cfg/lib/versionMatch.js +25 -0
- package/dist/generators/cfg/lib/versionResolve.d.ts +10 -0
- package/dist/generators/cfg/lib/versionResolve.d.ts.map +1 -0
- package/dist/generators/cfg/lib/versionResolve.js +49 -0
- package/dist/generators/cfg/schema.d.ts +5 -0
- package/dist/generators/cfg/schema.json +33 -0
- package/dist/generators/mv/mv-generator.d.ts +5 -0
- package/dist/generators/mv/mv-generator.d.ts.map +1 -0
- package/dist/generators/mv/mv-generator.js +11 -0
- package/dist/generators/mv/schema.d.ts +4 -0
- package/dist/generators/mv/schema.json +24 -0
- package/dist/generators/pkg/__snapshots__/pkg-generator.spec.ts.snap +297 -0
- package/dist/generators/pkg/lib/tsPathsBased.d.ts +4 -0
- package/dist/generators/pkg/lib/tsPathsBased.d.ts.map +1 -0
- package/dist/generators/pkg/lib/tsPathsBased.js +54 -0
- package/dist/generators/pkg/lib/tsReferenceBased.d.ts +4 -0
- package/dist/generators/pkg/lib/tsReferenceBased.d.ts.map +1 -0
- package/dist/generators/pkg/lib/tsReferenceBased.js +62 -0
- package/dist/generators/pkg/lib/util/addLocalPackage.d.ts +20 -0
- package/dist/generators/pkg/lib/util/addLocalPackage.d.ts.map +1 -0
- package/dist/generators/pkg/lib/util/addLocalPackage.js +48 -0
- package/dist/generators/pkg/lib/util/addPublishInfoToPackageJson.d.ts +3 -0
- package/dist/generators/pkg/lib/util/addPublishInfoToPackageJson.d.ts.map +1 -0
- package/dist/generators/pkg/lib/util/addPublishInfoToPackageJson.js +33 -0
- package/dist/generators/pkg/lib/util/resolveViteConfigPath.d.ts +7 -0
- package/dist/generators/pkg/lib/util/resolveViteConfigPath.d.ts.map +1 -0
- package/dist/generators/pkg/lib/util/resolveViteConfigPath.js +13 -0
- package/dist/generators/pkg/lib/util/setJsTsOptions.d.ts +3 -0
- package/dist/generators/pkg/lib/util/setJsTsOptions.d.ts.map +1 -0
- package/dist/generators/pkg/lib/util/setJsTsOptions.js +16 -0
- package/dist/generators/pkg/lib/util/setNextTsOptions.d.ts +3 -0
- package/dist/generators/pkg/lib/util/setNextTsOptions.d.ts.map +1 -0
- package/dist/generators/pkg/lib/util/setNextTsOptions.js +13 -0
- package/dist/generators/pkg/lib/util/setReactTsOptions.d.ts +3 -0
- package/dist/generators/pkg/lib/util/setReactTsOptions.d.ts.map +1 -0
- package/dist/generators/pkg/lib/util/setReactTsOptions.js +64 -0
- package/dist/generators/pkg/lib/util/updateArrayProperty.d.ts +2 -0
- package/dist/generators/pkg/lib/util/updateArrayProperty.d.ts.map +1 -0
- package/dist/generators/pkg/lib/util/updateArrayProperty.js +4 -0
- package/dist/generators/pkg/lib/util/updateTsConfigLibJson.d.ts +3 -0
- package/dist/generators/pkg/lib/util/updateTsConfigLibJson.d.ts.map +1 -0
- package/dist/generators/pkg/lib/util/updateTsConfigLibJson.js +4 -0
- package/dist/generators/pkg/lib/util/updateTsConfigSpecJson.d.ts +3 -0
- package/dist/generators/pkg/lib/util/updateTsConfigSpecJson.d.ts.map +1 -0
- package/dist/generators/pkg/lib/util/updateTsConfigSpecJson.js +4 -0
- package/dist/generators/pkg/lib/util/updateViteBuildFormats.d.ts +8 -0
- package/dist/generators/pkg/lib/util/updateViteBuildFormats.d.ts.map +1 -0
- package/dist/generators/pkg/lib/util/updateViteBuildFormats.js +16 -0
- package/dist/generators/pkg/lib/util/updateVitestConfig.d.ts +4 -0
- package/dist/generators/pkg/lib/util/updateVitestConfig.d.ts.map +1 -0
- package/dist/generators/pkg/lib/util/updateVitestConfig.js +29 -0
- package/dist/generators/pkg/pkg-generator.d.ts +5 -0
- package/dist/generators/pkg/pkg-generator.d.ts.map +1 -0
- package/dist/generators/pkg/pkg-generator.js +19 -0
- package/dist/generators/pkg/schema.d.ts +8 -0
- package/dist/generators/pkg/schema.json +66 -0
- package/dist/generators/rm/rm-generator.d.ts +5 -0
- package/dist/generators/rm/rm-generator.d.ts.map +1 -0
- package/dist/generators/rm/rm-generator.js +19 -0
- package/dist/generators/rm/schema.d.ts +3 -0
- package/dist/generators/rm/schema.json +19 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/generators.json +24 -0
- package/package.json +90 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
---
|
|
2
|
+
description:
|
|
3
|
+
globs:
|
|
4
|
+
alwaysApply: true
|
|
5
|
+
---
|
|
6
|
+
# TypeScript Rules
|
|
7
|
+
|
|
8
|
+
USE WHEN editing/creating/writing/engineering/architecting any TypeScript (.ts or .tsx) Code
|
|
9
|
+
These rules relevant to any typescript-related work and should be applied on top of the @core.mdc rules
|
|
10
|
+
|
|
11
|
+
## MCP Context & Documentation Lookup
|
|
12
|
+
- **Context First:** Always query MCP documentation tools (e.g. `context7`) for the latest official docs, examples, and type definitions.
|
|
13
|
+
- **Fallback:** If MCP yields incomplete info, perform a web search against authoritative sources (TypeScript Handbook, official library sites).
|
|
14
|
+
- **Integrate Findings:** Merge examples or code snippets from MCP/web search into your solution—adapt, do not copy verbatim.
|
|
15
|
+
|
|
16
|
+
## Monorepo & Nx Awareness
|
|
17
|
+
- Detect an Nx workspace by presence of `nx.json`
|
|
18
|
+
- Run `cd` to the monorepo root **in a separate command** before issuing any `nx` CLI calls.
|
|
19
|
+
- Use Nx commands (`nx build`, `nx test`, `nx g`) rather than ad-hoc scripts, so project boundaries and dependencies are respected.
|
|
20
|
+
- If an Nx MCP tool is available (e.g. `nx_workspace`, `nx_docs`), leverage it for workspace graph queries and code generation.
|
|
21
|
+
|
|
22
|
+
## Package Manager
|
|
23
|
+
- Always check what package manager is being used in the project.
|
|
24
|
+
- Use the correct package manager to call scripts (eg `pnpm dlx` instead of `npx` and `pnpm start` instead of `npm start` and so on)
|
|
25
|
+
|
|
26
|
+
## TypeScript Code Standards
|
|
27
|
+
- **Self-Documenting Code:** Favor clear, descriptive names and types over comments.
|
|
28
|
+
- **Pure & Composable:** Write small, pure functions and modules. Prefer functional patterns (`map`, `filter`, pipelines) over imperative loops.
|
|
29
|
+
- **No Clever Tricks:** Avoid deeply nested logic and complex `.reduce()` chains; extract helpers if needed.
|
|
30
|
+
- **ES Modules Only:** Use `import`/`export`; do not use `namespace` syntax.
|
|
31
|
+
- **No Native Enums:**
|
|
32
|
+
- If `@space-arch/util-enum` is installed, use its API.
|
|
33
|
+
- Otherwise, define “enum objects” with `as const` and string-literal unions:
|
|
34
|
+
```ts
|
|
35
|
+
export const FOO = { A: 'A', B: 'B' } as const;
|
|
36
|
+
export type Foo = (typeof FOO)[keyof typeof FOO];
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Error Handling
|
|
40
|
+
- Check if the project uses `neverthrow` npm package.
|
|
41
|
+
- if project uses `neverthrow`, Wrap risky code in utils from the `neverthrow` library.
|
|
42
|
+
- Avoid manually typing the return type - let TS infer the type.
|
|
43
|
+
- Define error codes as enum objects (using `@space-arch/util-enum` utilities like `enumPrefixed`).
|
|
44
|
+
- If project DOES NOT use `neverthrow` follow standard error handling best-practices
|
|
45
|
+
|
|
46
|
+
## Modern Language & Compiler Features
|
|
47
|
+
- Read `lib` and `target` from the project's `tsconfig.json`/`tsconfig.base.json`.
|
|
48
|
+
- If `lib` and `target` are set to ESNext you should use all the latest cutting edge language features and specs
|
|
49
|
+
- If `lib` and `target` are set to `ES20xx` you should use corresponding latest ECMAScript language features and specs
|
|
50
|
+
- Use all latest supported ES/TS features (optional chaining, nullish coalescing, top-level await, `replaceAll`, etc.).
|
|
51
|
+
- Avoid down-leveling unless required for compatibility.
|
|
52
|
+
|
|
53
|
+
## Testing & Verification
|
|
54
|
+
- Write or update unit tests for new code or bug fixes using the project's test framework.
|
|
55
|
+
- Run the TypeScript compiler (`tsc`), ESLint, and test runner via MCP or CLI—do not finalize until all pass.
|
|
56
|
+
- In an Nx monorepo, prefer nx commands like `nx test`, `nx lint`, `nx build` over direct tool calls.
|
|
57
|
+
- Make sure the tests pass.
|
|
58
|
+
|
|
59
|
+
## Documentation & Comments
|
|
60
|
+
- Only add comments to explain *why* a non-obvious decision exists; avoid “what” comments.
|
|
61
|
+
- Use JSDoc/TSDoc for public APIs; keep descriptions brief and to-the-point.
|
|
62
|
+
- Do not document self-explanatory code: strive for code clarity instead.
|
|
63
|
+
- Update README or project docs only if usage or setup has changed.
|
|
64
|
+
|
|
65
|
+
## Output Formatting & Code Style
|
|
66
|
+
- Adhere to the project's Prettier and ESLint configurations.
|
|
67
|
+
- Follow best practices
|
|
68
|
+
|
|
69
|
+
## Communication & Proactive Suggestions
|
|
70
|
+
- Present only relevant diffs or code snippets; avoid full-file dumps.
|
|
71
|
+
- If requirements are ambiguous, ask a concise clarification question.
|
|
72
|
+
- After fulfilling the user's request, you may offer up to **two** brief, optional improvement suggestions—clearly label them as “Optional: …”.
|
|
73
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"semi": true,
|
|
3
|
+
"singleQuote": true,
|
|
4
|
+
"trailingComma": "all",
|
|
5
|
+
"tabWidth": 2,
|
|
6
|
+
"bracketSpacing": true,
|
|
7
|
+
"arrowParens": "avoid",
|
|
8
|
+
"printWidth": 80,
|
|
9
|
+
"proseWrap": "always",
|
|
10
|
+
"plugins": [
|
|
11
|
+
"@trivago/prettier-plugin-sort-imports",
|
|
12
|
+
"prettier-plugin-tailwindcss",
|
|
13
|
+
"prettier-plugin-classnames",
|
|
14
|
+
"prettier-plugin-merge"
|
|
15
|
+
],
|
|
16
|
+
"importOrder": [
|
|
17
|
+
"^server-only$",
|
|
18
|
+
"<THIRD_PARTY_MODULES>",
|
|
19
|
+
"^@com\\/web-ui\\/(shadcn|lib|hooks)\\/",
|
|
20
|
+
"^@com\\/web-ui\\/components\\/",
|
|
21
|
+
"^@com\\/",
|
|
22
|
+
"^.+\\/shadcn\\/",
|
|
23
|
+
"^\\.\\./",
|
|
24
|
+
"^\\./"
|
|
25
|
+
],
|
|
26
|
+
"importOrderSeparation": true,
|
|
27
|
+
"importOrderSortSpecifiers": true,
|
|
28
|
+
"tailwindStylesheet": "./com/web/app/src/app/global.css",
|
|
29
|
+
"tailwindConfig": "./com/web/app/tailwind.config.js",
|
|
30
|
+
"tailwindFunctions": ["clsx", "cn", "cva"],
|
|
31
|
+
"customFunctions": ["clsx", "cn", "cva"]
|
|
32
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import nx from '@nx/eslint-plugin';
|
|
2
|
+
import prettierRecommended from 'eslint-plugin-prettier/recommended';
|
|
3
|
+
|
|
4
|
+
export default [
|
|
5
|
+
{
|
|
6
|
+
files: ['**/*.json'],
|
|
7
|
+
// Override or add rules here
|
|
8
|
+
rules: {},
|
|
9
|
+
languageOptions: {
|
|
10
|
+
parser: await import('jsonc-eslint-parser'),
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
...nx.configs['flat/base'],
|
|
15
|
+
...nx.configs['flat/typescript'],
|
|
16
|
+
...nx.configs['flat/javascript'],
|
|
17
|
+
|
|
18
|
+
prettierRecommended,
|
|
19
|
+
|
|
20
|
+
{
|
|
21
|
+
ignores: [
|
|
22
|
+
'local/**',
|
|
23
|
+
'tmp/**',
|
|
24
|
+
'**/generated',
|
|
25
|
+
'**/dist',
|
|
26
|
+
'**/vite.config.*.timestamp*',
|
|
27
|
+
'**/vitest.config.*.timestamp*',
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
|
|
32
|
+
rules: {
|
|
33
|
+
'@nx/enforce-module-boundaries': [
|
|
34
|
+
'error',
|
|
35
|
+
{
|
|
36
|
+
enforceBuildableLibDependency: true,
|
|
37
|
+
allow: ['^.*/eslint(\\.base)?\\.config\\.[cm]?js$'],
|
|
38
|
+
depConstraints: [
|
|
39
|
+
{
|
|
40
|
+
sourceTag: '*',
|
|
41
|
+
onlyDependOnLibsWithTags: ['*'],
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
files: [
|
|
50
|
+
'**/*.ts',
|
|
51
|
+
'**/*.tsx',
|
|
52
|
+
'**/*.cts',
|
|
53
|
+
'**/*.mts',
|
|
54
|
+
'**/*.js',
|
|
55
|
+
'**/*.jsx',
|
|
56
|
+
'**/*.cjs',
|
|
57
|
+
'**/*.mjs',
|
|
58
|
+
],
|
|
59
|
+
rules: {
|
|
60
|
+
'no-multiple-empty-lines': ['error', { max: 1, maxEOF: 1 }],
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
files: ['**/*.js', '**/*.jsx'],
|
|
65
|
+
rules: {
|
|
66
|
+
'no-unused-vars': [
|
|
67
|
+
'error',
|
|
68
|
+
{
|
|
69
|
+
varsIgnorePattern: '^_',
|
|
70
|
+
argsIgnorePattern: '^_',
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
files: ['**/*.ts', '**/*.tsx'],
|
|
77
|
+
rules: {
|
|
78
|
+
'no-multiple-empty-lines': ['error', { max: 1, maxEOF: 1 }],
|
|
79
|
+
'tailwindcss/no-custom-classname': 'off',
|
|
80
|
+
'no-unused-vars': 'off',
|
|
81
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
82
|
+
'@typescript-eslint/no-unused-vars': [
|
|
83
|
+
'error',
|
|
84
|
+
{
|
|
85
|
+
varsIgnorePattern: '^_',
|
|
86
|
+
argsIgnorePattern: '^_',
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initCursorRules.d.ts","sourceRoot":"","sources":["../../../../src/generators/cfg/lib/initCursorRules.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,IAAI,EAGV,MAAM,YAAY,CAAC;AAEpB,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,QAQ5D"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { OverwriteStrategy, generateFiles, joinPathFragments, } from '@nx/devkit';
|
|
2
|
+
export function initCursorRules(tree, namespace) {
|
|
3
|
+
generateFiles(tree, joinPathFragments(__dirname, '../files/cursor-rules'), '.cursor/rules', { namespace }, { overwriteStrategy: OverwriteStrategy.Overwrite });
|
|
4
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initEslintAndPrettierConfigs.d.ts","sourceRoot":"","sources":["../../../../src/generators/cfg/lib/initEslintAndPrettierConfigs.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,IAAI,EAIV,MAAM,YAAY,CAAC;AAIpB,wBAAsB,4BAA4B,CAChD,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,MAAM,iBA2BlB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { OverwriteStrategy, addDependenciesToPackageJson, generateFiles, joinPathFragments, } from '@nx/devkit';
|
|
2
|
+
import { versionResolve } from "./versionResolve.js";
|
|
3
|
+
export async function initEslintAndPrettierConfigs(tree, namespace) {
|
|
4
|
+
const devDependencies = await versionResolve({
|
|
5
|
+
prettier: 'latest',
|
|
6
|
+
'@trivago/prettier-plugin-sort-imports': 'latest',
|
|
7
|
+
'prettier-plugin-tailwindcss': 'latest',
|
|
8
|
+
'prettier-plugin-classnames': 'latest',
|
|
9
|
+
'prettier-plugin-merge': 'latest',
|
|
10
|
+
eslint: 'latest',
|
|
11
|
+
'eslint-config-prettier': 'latest',
|
|
12
|
+
'eslint-plugin-prettier': 'latest',
|
|
13
|
+
'@eslint/js': 'latest',
|
|
14
|
+
'jsonc-eslint-parser': 'latest',
|
|
15
|
+
typescript: 'latest',
|
|
16
|
+
'typescript-eslint': 'latest',
|
|
17
|
+
'@types/node': 'latest',
|
|
18
|
+
});
|
|
19
|
+
addDependenciesToPackageJson(tree, {}, devDependencies);
|
|
20
|
+
generateFiles(tree, joinPathFragments(__dirname, '../files/lint'), '.', { namespace }, { overwriteStrategy: OverwriteStrategy.Overwrite });
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"versionMatch.d.ts","sourceRoot":"","sources":["../../../../src/generators/cfg/lib/versionMatch.ts"],"names":[],"mappings":"AAAA,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAAE,EAClB,UAAU,EAAE,MAAM,GACjB,MAAM,GAAG,IAAI,CAcf;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAa5D"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function versionMatchLatest(versions, constraint) {
|
|
2
|
+
// Convert constraint like "2.3.*" to regex pattern
|
|
3
|
+
const pattern = constraint.replace(/\*/g, '\\d+');
|
|
4
|
+
const regex = new RegExp(`^${pattern}$`);
|
|
5
|
+
// Filter versions that match the constraint
|
|
6
|
+
const matchingVersions = versions.filter(version => regex.test(version));
|
|
7
|
+
if (matchingVersions.length === 0) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
// Sort versions using semver-like comparison and return the latest
|
|
11
|
+
return matchingVersions.sort((a, b) => compareVersions(a, b)).pop() || null;
|
|
12
|
+
}
|
|
13
|
+
export function compareVersions(a, b) {
|
|
14
|
+
const aParts = a.split('.').map(Number);
|
|
15
|
+
const bParts = b.split('.').map(Number);
|
|
16
|
+
for (let i = 0; i < Math.max(aParts.length, bParts.length); i++) {
|
|
17
|
+
const aPart = aParts[i] || 0;
|
|
18
|
+
const bPart = bParts[i] || 0;
|
|
19
|
+
if (aPart > bPart)
|
|
20
|
+
return 1;
|
|
21
|
+
if (aPart < bPart)
|
|
22
|
+
return -1;
|
|
23
|
+
}
|
|
24
|
+
return 0;
|
|
25
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type VersionConstraintSegment = `${number | '*'}`;
|
|
2
|
+
export type VersionConstraint = 'latest' | 'canary' | `${'^' | '~' | '>' | '<' | '>=' | '<=' | '=' | '!='}${string}` | `${VersionConstraintSegment}.${VersionConstraintSegment}.${VersionConstraintSegment}`;
|
|
3
|
+
/**
|
|
4
|
+
* Resolves versions matching constraints from npm registry.
|
|
5
|
+
* @param packages - A record of package names and their version constraints
|
|
6
|
+
* @returns A record of package names and their resolved versions
|
|
7
|
+
*/
|
|
8
|
+
export declare function versionResolve(packages: Record<string, VersionConstraint>): Promise<Record<string, string>>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=versionResolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"versionResolve.d.ts","sourceRoot":"","sources":["../../../../src/generators/cfg/lib/versionResolve.ts"],"names":[],"mappings":"AAIA,KAAK,wBAAwB,GAAG,GAAG,MAAM,GAAG,GAAG,EAAE,CAAC;AAClD,MAAM,MAAM,iBAAiB,GACzB,QAAQ,GACR,QAAQ,GACR,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,MAAM,EAAE,GAC9D,GAAG,wBAAwB,IAAI,wBAAwB,IAAI,wBAAwB,EAAE,CAAC;AAE1F;;;;GAIG;AACH,wBAAsB,cAAc,CAClC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAC1C,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAOjC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { logger } from '@nx/devkit';
|
|
2
|
+
import { versionMatchLatest } from "./versionMatch.js";
|
|
3
|
+
/**
|
|
4
|
+
* Resolves versions matching constraints from npm registry.
|
|
5
|
+
* @param packages - A record of package names and their version constraints
|
|
6
|
+
* @returns A record of package names and their resolved versions
|
|
7
|
+
*/
|
|
8
|
+
export async function versionResolve(packages) {
|
|
9
|
+
const promises = Object.entries(packages).map(([name, constraint]) => resolveOne(name, constraint));
|
|
10
|
+
const results = await Promise.all(promises);
|
|
11
|
+
return Object.fromEntries(results);
|
|
12
|
+
}
|
|
13
|
+
//-------------------------------------
|
|
14
|
+
function shouldFetch(constraint) {
|
|
15
|
+
return (constraint === 'latest' ||
|
|
16
|
+
constraint === 'canary' ||
|
|
17
|
+
constraint.includes('*'));
|
|
18
|
+
}
|
|
19
|
+
async function packageFetch(packageName) {
|
|
20
|
+
const response = await fetch(`https://registry.npmjs.org/${packageName}`);
|
|
21
|
+
if (!response.ok) {
|
|
22
|
+
throw new Error(`HTTP ${response.status}`);
|
|
23
|
+
}
|
|
24
|
+
return response.json();
|
|
25
|
+
}
|
|
26
|
+
function constraintApply(constraint, packageData) {
|
|
27
|
+
if (constraint === 'latest') {
|
|
28
|
+
return packageData['dist-tags'].latest;
|
|
29
|
+
}
|
|
30
|
+
if (constraint === 'canary') {
|
|
31
|
+
return packageData['dist-tags'].canary || packageData['dist-tags'].latest;
|
|
32
|
+
}
|
|
33
|
+
// Handle version constraints like "2.3.*", "1.*.*"
|
|
34
|
+
const matchingVersion = versionMatchLatest(Object.keys(packageData.versions), constraint);
|
|
35
|
+
return matchingVersion || constraint;
|
|
36
|
+
}
|
|
37
|
+
async function resolveOne(packageName, constraint) {
|
|
38
|
+
if (!shouldFetch(constraint))
|
|
39
|
+
return [packageName, constraint];
|
|
40
|
+
try {
|
|
41
|
+
const packageData = await packageFetch(packageName);
|
|
42
|
+
const resolvedVersion = constraintApply(constraint, packageData);
|
|
43
|
+
return [packageName, resolvedVersion];
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
logger.warn(`Failed to fetch version for ${packageName}: ${error.message}, using fallback`);
|
|
47
|
+
return [packageName, constraint];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "Init",
|
|
4
|
+
"title": "",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"options": {
|
|
8
|
+
"description": "The options to apply",
|
|
9
|
+
"type": "array",
|
|
10
|
+
"items": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"enum": ["cursor-rules", "lint"]
|
|
13
|
+
},
|
|
14
|
+
"default": ["cursor-rules", "lint"],
|
|
15
|
+
"x-prompt": {
|
|
16
|
+
"type": "list",
|
|
17
|
+
"message": "Select the options you want to apply",
|
|
18
|
+
"multiselect": true,
|
|
19
|
+
"items": [
|
|
20
|
+
{
|
|
21
|
+
"label": "cursor-rules",
|
|
22
|
+
"value": "cursor-rules"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"label": "lint",
|
|
26
|
+
"value": "lint"
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"required": ["options"]
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mv-generator.d.ts","sourceRoot":"","sources":["../../../src/generators/mv/mv-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD,wBAAsB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,iBAAiB,iBASvE;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { moveGenerator } from '@nx/workspace';
|
|
2
|
+
export async function mvGenerator(tree, options) {
|
|
3
|
+
const { packageName, newPath } = options;
|
|
4
|
+
await moveGenerator(tree, {
|
|
5
|
+
projectName: packageName,
|
|
6
|
+
destination: newPath,
|
|
7
|
+
updateImportPath: true,
|
|
8
|
+
newProjectName: newPath.split('/').slice(1).join('-'),
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export default mvGenerator;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "Mv",
|
|
4
|
+
"title": "",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"packageName": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "The name of the package to move",
|
|
10
|
+
"$default": {
|
|
11
|
+
"$source": "argv",
|
|
12
|
+
"index": 0
|
|
13
|
+
},
|
|
14
|
+
"x-prompt": "What package name would you like to move?",
|
|
15
|
+
"x-dropdown": "projects"
|
|
16
|
+
},
|
|
17
|
+
"newPath": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"description": "The new path of the package",
|
|
20
|
+
"x-prompt": "What is the new path of the package?"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"required": ["packageName", "newPath"]
|
|
24
|
+
}
|