@aws/nx-plugin 1.0.0-rc.49 → 1.0.0-rc.50
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/LICENSE-THIRD-PARTY +436 -29
- package/migrations.json +17 -1
- package/package.json +2 -1
- package/src/migrations/latest/modernize-function-props-cast/migration.d.ts +6 -0
- package/src/migrations/latest/modernize-function-props-cast/migration.js +66 -0
- package/src/migrations/latest/modernize-function-props-cast/migration.js.map +1 -0
- package/src/migrations/latest/restrict-cors-to-custom-domains/migration.d.ts +6 -0
- package/src/migrations/latest/restrict-cors-to-custom-domains/migration.js +110 -0
- package/src/migrations/latest/restrict-cors-to-custom-domains/migration.js.map +1 -0
- package/src/migrations/latest/terraform-bootstrap-adopt-existing-bucket/migration.d.ts +6 -0
- package/src/migrations/latest/terraform-bootstrap-adopt-existing-bucket/migration.js +129 -0
- package/src/migrations/latest/terraform-bootstrap-adopt-existing-bucket/migration.js.map +1 -0
- package/src/py/agent/__snapshots__/generator.constructs.spec.ts.snap +1 -0
- package/src/py/fast-api/__snapshots__/generator.spec.ts.snap +25 -15
- package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +1 -0
- package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +26 -16
- package/src/terraform/project/files/application/scripts/bootstrap.ts.template +40 -1
- package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +75 -45
- package/src/ts/agent/__snapshots__/generator.spec.ts.snap +1 -0
- package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +1 -0
- package/src/ts/nx-migration/files/migration.ts.template +6 -0
- package/src/ts/rdb/__snapshots__/generator.spec.ts.snap +1 -0
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +43 -0
- package/src/ts/react-website/cognito-auth/__snapshots__/generator.spec.ts.snap +11 -14
- package/src/utils/__snapshots__/shared-constructs.spec.ts.snap +21 -0
- package/src/utils/api-constructs/files/cdk/app/apis/http/__apiNameKebabCase__.ts.template +12 -7
- package/src/utils/api-constructs/files/cdk/app/apis/rest/__apiNameKebabCase__.ts.template +13 -8
- package/src/utils/files/common/constructs/src/core/cloudfront.ts.template +14 -0
- package/src/utils/files/common/constructs/src/core/index.ts.template +1 -0
- package/src/utils/format.js +118 -240
- package/src/utils/format.js.map +1 -1
- package/src/utils/identity-constructs/files/cdk/core/user-identity.ts.template +7 -14
- package/src/utils/ruff.d.ts +59 -0
- package/src/utils/ruff.js +140 -0
- package/src/utils/ruff.js.map +1 -0
- package/src/utils/toml.d.ts +5 -0
- package/src/utils/toml.js +10 -0
- package/src/utils/toml.js.map +1 -1
- package/src/utils/warm-ruff-cache.d.ts +0 -8
- package/src/utils/warm-ruff-cache.js +0 -30
- package/src/utils/warm-ruff-cache.js.map +0 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Rules whose fixes are applied to generated Python.
|
|
7
|
+
*
|
|
8
|
+
* `ruff_wasm`'s `check` serialises every fix without its applicability (the
|
|
9
|
+
* `Fix::applicability()` it drops is what `ruff check --fix` filters on) and
|
|
10
|
+
* ignores `unsafe-fixes`, so it cannot be asked for only the fixes the CLI would
|
|
11
|
+
* apply. Taking them all would rewrite `if x == True` to `if x`.
|
|
12
|
+
*
|
|
13
|
+
* Ruff's `fixable` setting filters inside the linter, which keeps the decision
|
|
14
|
+
* in ruff — but it selects by *rule*, and applicability is a property of each
|
|
15
|
+
* *diagnostic*: across ruff's own 1598 lint fixtures, 27 rules under the vended
|
|
16
|
+
* selection emit both safe and unsafe fixes depending on the code (one `UP008`
|
|
17
|
+
* is safe, another is unsafe when dropping the arguments would take a comment
|
|
18
|
+
* with them). So no rule list, allowing or denying, can reproduce `--fix`: for
|
|
19
|
+
* those 27 it can only take both or neither.
|
|
20
|
+
*
|
|
21
|
+
* Given that, the list stays as small as generation needs rather than reaching
|
|
22
|
+
* for an equivalence it cannot have. These four cover the import hygiene
|
|
23
|
+
* generation itself creates by merging imports into existing files, and ruff
|
|
24
|
+
* documents each of their fixes as safe — except F401 in an `__init__.py`, which
|
|
25
|
+
* is excluded below. Templates are authored free of other violations, so nothing
|
|
26
|
+
* else needs fixing here, and the user's own `lint --configuration=fix` remains
|
|
27
|
+
* the full-fidelity path. A test re-checks these against ruff's own docs.
|
|
28
|
+
*/
|
|
29
|
+
export declare const FIXABLE_RULES: string[];
|
|
30
|
+
/**
|
|
31
|
+
* The ruff release these bindings are built from. `@astral-sh/ruff-wasm-nodejs`
|
|
32
|
+
* is published from the ruff repo on every release, so its versions track ruff's
|
|
33
|
+
* exactly — keep this in step with `PY_VERSIONS.ruff` (the ruff the vended
|
|
34
|
+
* `format` and `lint` targets run) so generated files stay `ruff format
|
|
35
|
+
* --check`-clean on disk. A test asserts the two agree.
|
|
36
|
+
*/
|
|
37
|
+
export declare const RUFF_WASM_VERSION: string;
|
|
38
|
+
/** Ruff settings, as accepted by the WASM `Workspace` constructor. */
|
|
39
|
+
export interface RuffOptions {
|
|
40
|
+
readonly 'line-length'?: number;
|
|
41
|
+
readonly 'target-version'?: string;
|
|
42
|
+
readonly lint?: {
|
|
43
|
+
readonly select?: readonly string[];
|
|
44
|
+
readonly 'extend-select'?: readonly string[];
|
|
45
|
+
readonly fixable?: readonly string[];
|
|
46
|
+
readonly unfixable?: readonly string[];
|
|
47
|
+
readonly isort?: {
|
|
48
|
+
readonly 'known-first-party'?: readonly string[];
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Apply ruff's lint fixes and formatter to Python content, in process.
|
|
54
|
+
*
|
|
55
|
+
* Equivalent to piping the content through `ruff check --fix` then `ruff
|
|
56
|
+
* format` — the tools the vended `lint` and `format` targets run — without
|
|
57
|
+
* paying two process spawns per file.
|
|
58
|
+
*/
|
|
59
|
+
export declare const ruffFixAndFormat: (content: string, filePath: string, options: RuffOptions) => string;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/ import { PositionEncoding, Workspace } from "@astral-sh/ruff-wasm-nodejs";
|
|
5
|
+
import path from "path";
|
|
6
|
+
/**
|
|
7
|
+
* Rules whose fixes are applied to generated Python.
|
|
8
|
+
*
|
|
9
|
+
* `ruff_wasm`'s `check` serialises every fix without its applicability (the
|
|
10
|
+
* `Fix::applicability()` it drops is what `ruff check --fix` filters on) and
|
|
11
|
+
* ignores `unsafe-fixes`, so it cannot be asked for only the fixes the CLI would
|
|
12
|
+
* apply. Taking them all would rewrite `if x == True` to `if x`.
|
|
13
|
+
*
|
|
14
|
+
* Ruff's `fixable` setting filters inside the linter, which keeps the decision
|
|
15
|
+
* in ruff — but it selects by *rule*, and applicability is a property of each
|
|
16
|
+
* *diagnostic*: across ruff's own 1598 lint fixtures, 27 rules under the vended
|
|
17
|
+
* selection emit both safe and unsafe fixes depending on the code (one `UP008`
|
|
18
|
+
* is safe, another is unsafe when dropping the arguments would take a comment
|
|
19
|
+
* with them). So no rule list, allowing or denying, can reproduce `--fix`: for
|
|
20
|
+
* those 27 it can only take both or neither.
|
|
21
|
+
*
|
|
22
|
+
* Given that, the list stays as small as generation needs rather than reaching
|
|
23
|
+
* for an equivalence it cannot have. These four cover the import hygiene
|
|
24
|
+
* generation itself creates by merging imports into existing files, and ruff
|
|
25
|
+
* documents each of their fixes as safe — except F401 in an `__init__.py`, which
|
|
26
|
+
* is excluded below. Templates are authored free of other violations, so nothing
|
|
27
|
+
* else needs fixing here, and the user's own `lint --configuration=fix` remains
|
|
28
|
+
* the full-fidelity path. A test re-checks these against ruff's own docs.
|
|
29
|
+
*/ export const FIXABLE_RULES = [
|
|
30
|
+
'I001',
|
|
31
|
+
'F401',
|
|
32
|
+
'F811',
|
|
33
|
+
'E401'
|
|
34
|
+
];
|
|
35
|
+
/** Escape hatch matching ruff's own fix loop bound. */ const MAX_FIX_ITERATIONS = 100;
|
|
36
|
+
/**
|
|
37
|
+
* The ruff release these bindings are built from. `@astral-sh/ruff-wasm-nodejs`
|
|
38
|
+
* is published from the ruff repo on every release, so its versions track ruff's
|
|
39
|
+
* exactly — keep this in step with `PY_VERSIONS.ruff` (the ruff the vended
|
|
40
|
+
* `format` and `lint` targets run) so generated files stay `ruff format
|
|
41
|
+
* --check`-clean on disk. A test asserts the two agree.
|
|
42
|
+
*/ export const RUFF_WASM_VERSION = Workspace.version();
|
|
43
|
+
/**
|
|
44
|
+
* Apply one diagnostic's fix, resolving ruff's (row, column) positions against
|
|
45
|
+
* the content. Positions are requested in UTF-16, which is how JavaScript
|
|
46
|
+
* already indexes strings, so they need no transcoding.
|
|
47
|
+
*/ const applyFix = (content, edits)=>{
|
|
48
|
+
const lineStarts = [
|
|
49
|
+
0
|
|
50
|
+
];
|
|
51
|
+
for(let i = 0; i < content.length; i++){
|
|
52
|
+
if (content[i] === '\n') {
|
|
53
|
+
lineStarts.push(i + 1);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// Ruff can report a position one past the last line (eg when deleting a
|
|
57
|
+
// trailing line), so clamp rather than indexing past the end.
|
|
58
|
+
const offsetOf = (location)=>(lineStarts[location.row - 1] ?? content.length) + (location.column - 1);
|
|
59
|
+
let result = '';
|
|
60
|
+
let end = 0;
|
|
61
|
+
for (const edit of [
|
|
62
|
+
...edits
|
|
63
|
+
].sort((a, b)=>offsetOf(a.location) - offsetOf(b.location))){
|
|
64
|
+
const start = offsetOf(edit.location);
|
|
65
|
+
if (start < end) {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
result += content.slice(end, start) + (edit.content ?? '');
|
|
69
|
+
end = offsetOf(edit.end_location);
|
|
70
|
+
}
|
|
71
|
+
return result + content.slice(end);
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Ruff treats an `__init__.py` as re-exporting its imports, so an unused import
|
|
75
|
+
* there gets a diagnostic with no fix — removing it would drop the package's
|
|
76
|
+
* public API. `ruff_wasm` lints under a fixed placeholder filename and so cannot
|
|
77
|
+
* apply this itself, making the file's real name the caller's to account for.
|
|
78
|
+
*/ const isInitPy = (filePath)=>path.basename(filePath) === '__init__.py';
|
|
79
|
+
/**
|
|
80
|
+
* A `Workspace` costs far more to construct than to run, and the same settings
|
|
81
|
+
* recur across every file of a project, so key them by the resolved options.
|
|
82
|
+
*/ const _workspaces = new Map();
|
|
83
|
+
const getWorkspace = (options)=>{
|
|
84
|
+
const key = JSON.stringify(options);
|
|
85
|
+
let workspace = _workspaces.get(key);
|
|
86
|
+
if (!workspace) {
|
|
87
|
+
workspace = new Workspace(options, PositionEncoding.Utf16);
|
|
88
|
+
_workspaces.set(key, workspace);
|
|
89
|
+
}
|
|
90
|
+
return workspace;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Apply ruff's lint fixes and formatter to Python content, in process.
|
|
94
|
+
*
|
|
95
|
+
* Equivalent to piping the content through `ruff check --fix` then `ruff
|
|
96
|
+
* format` — the tools the vended `lint` and `format` targets run — without
|
|
97
|
+
* paying two process spawns per file.
|
|
98
|
+
*/ export const ruffFixAndFormat = (content, filePath, options)=>{
|
|
99
|
+
const workspace = getWorkspace({
|
|
100
|
+
...options,
|
|
101
|
+
lint: {
|
|
102
|
+
...options.lint,
|
|
103
|
+
fixable: FIXABLE_RULES,
|
|
104
|
+
// Never drop an `__init__.py` import: ruff keeps these as re-exports.
|
|
105
|
+
...isInitPy(filePath) ? {
|
|
106
|
+
unfixable: [
|
|
107
|
+
'F401'
|
|
108
|
+
]
|
|
109
|
+
} : {}
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
// Apply a single fix per pass and re-lint, as ruff does until the content
|
|
113
|
+
// stabilises. Taking one fix at a time leaves ruff to decide what is
|
|
114
|
+
// applicable against the current content, rather than reproducing how it
|
|
115
|
+
// batches, orders and skips overlapping fixes within a pass.
|
|
116
|
+
for(let i = 0; i < MAX_FIX_ITERATIONS; i++){
|
|
117
|
+
let diagnostic;
|
|
118
|
+
try {
|
|
119
|
+
diagnostic = workspace.check(content).find((d)=>d.fix && d.fix.edits.length > 0);
|
|
120
|
+
} catch {
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
if (!diagnostic?.fix) {
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
const fixed = applyFix(content, diagnostic.fix.edits);
|
|
127
|
+
if (fixed === content) {
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
content = fixed;
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
return workspace.format(content);
|
|
134
|
+
} catch {
|
|
135
|
+
// Leave content the formatter rejects (eg a syntax error) as-is.
|
|
136
|
+
return content;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
//# sourceMappingURL=ruff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/ruff.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { PositionEncoding, Workspace } from '@astral-sh/ruff-wasm-nodejs';\nimport path from 'path';\n\n/**\n * Rules whose fixes are applied to generated Python.\n *\n * `ruff_wasm`'s `check` serialises every fix without its applicability (the\n * `Fix::applicability()` it drops is what `ruff check --fix` filters on) and\n * ignores `unsafe-fixes`, so it cannot be asked for only the fixes the CLI would\n * apply. Taking them all would rewrite `if x == True` to `if x`.\n *\n * Ruff's `fixable` setting filters inside the linter, which keeps the decision\n * in ruff — but it selects by *rule*, and applicability is a property of each\n * *diagnostic*: across ruff's own 1598 lint fixtures, 27 rules under the vended\n * selection emit both safe and unsafe fixes depending on the code (one `UP008`\n * is safe, another is unsafe when dropping the arguments would take a comment\n * with them). So no rule list, allowing or denying, can reproduce `--fix`: for\n * those 27 it can only take both or neither.\n *\n * Given that, the list stays as small as generation needs rather than reaching\n * for an equivalence it cannot have. These four cover the import hygiene\n * generation itself creates by merging imports into existing files, and ruff\n * documents each of their fixes as safe — except F401 in an `__init__.py`, which\n * is excluded below. Templates are authored free of other violations, so nothing\n * else needs fixing here, and the user's own `lint --configuration=fix` remains\n * the full-fidelity path. A test re-checks these against ruff's own docs.\n */\nexport const FIXABLE_RULES = ['I001', 'F401', 'F811', 'E401'];\n\n/** Escape hatch matching ruff's own fix loop bound. */\nconst MAX_FIX_ITERATIONS = 100;\n\n/**\n * The ruff release these bindings are built from. `@astral-sh/ruff-wasm-nodejs`\n * is published from the ruff repo on every release, so its versions track ruff's\n * exactly — keep this in step with `PY_VERSIONS.ruff` (the ruff the vended\n * `format` and `lint` targets run) so generated files stay `ruff format\n * --check`-clean on disk. A test asserts the two agree.\n */\nexport const RUFF_WASM_VERSION = Workspace.version();\n\ninterface Location {\n readonly row: number;\n readonly column: number;\n}\n\ninterface Edit {\n readonly content: string | null;\n readonly location: Location;\n readonly end_location: Location;\n}\n\ninterface Diagnostic {\n readonly fix: { readonly edits: readonly Edit[] } | null;\n}\n\n/** Ruff settings, as accepted by the WASM `Workspace` constructor. */\nexport interface RuffOptions {\n readonly 'line-length'?: number;\n readonly 'target-version'?: string;\n readonly lint?: {\n readonly select?: readonly string[];\n readonly 'extend-select'?: readonly string[];\n readonly fixable?: readonly string[];\n readonly unfixable?: readonly string[];\n readonly isort?: { readonly 'known-first-party'?: readonly string[] };\n };\n}\n\n/**\n * Apply one diagnostic's fix, resolving ruff's (row, column) positions against\n * the content. Positions are requested in UTF-16, which is how JavaScript\n * already indexes strings, so they need no transcoding.\n */\nconst applyFix = (content: string, edits: readonly Edit[]): string => {\n const lineStarts = [0];\n for (let i = 0; i < content.length; i++) {\n if (content[i] === '\\n') {\n lineStarts.push(i + 1);\n }\n }\n // Ruff can report a position one past the last line (eg when deleting a\n // trailing line), so clamp rather than indexing past the end.\n const offsetOf = (location: Location): number =>\n (lineStarts[location.row - 1] ?? content.length) + (location.column - 1);\n\n let result = '';\n let end = 0;\n for (const edit of [...edits].sort(\n (a, b) => offsetOf(a.location) - offsetOf(b.location),\n )) {\n const start = offsetOf(edit.location);\n if (start < end) {\n continue;\n }\n result += content.slice(end, start) + (edit.content ?? '');\n end = offsetOf(edit.end_location);\n }\n return result + content.slice(end);\n};\n\n/**\n * Ruff treats an `__init__.py` as re-exporting its imports, so an unused import\n * there gets a diagnostic with no fix — removing it would drop the package's\n * public API. `ruff_wasm` lints under a fixed placeholder filename and so cannot\n * apply this itself, making the file's real name the caller's to account for.\n */\nconst isInitPy = (filePath: string): boolean =>\n path.basename(filePath) === '__init__.py';\n\n/**\n * A `Workspace` costs far more to construct than to run, and the same settings\n * recur across every file of a project, so key them by the resolved options.\n */\nconst _workspaces = new Map<string, Workspace>();\nconst getWorkspace = (options: RuffOptions): Workspace => {\n const key = JSON.stringify(options);\n let workspace = _workspaces.get(key);\n if (!workspace) {\n workspace = new Workspace(options, PositionEncoding.Utf16);\n _workspaces.set(key, workspace);\n }\n return workspace;\n};\n\n/**\n * Apply ruff's lint fixes and formatter to Python content, in process.\n *\n * Equivalent to piping the content through `ruff check --fix` then `ruff\n * format` — the tools the vended `lint` and `format` targets run — without\n * paying two process spawns per file.\n */\nexport const ruffFixAndFormat = (\n content: string,\n filePath: string,\n options: RuffOptions,\n): string => {\n const workspace = getWorkspace({\n ...options,\n lint: {\n ...options.lint,\n fixable: FIXABLE_RULES,\n // Never drop an `__init__.py` import: ruff keeps these as re-exports.\n ...(isInitPy(filePath) ? { unfixable: ['F401'] } : {}),\n },\n });\n\n // Apply a single fix per pass and re-lint, as ruff does until the content\n // stabilises. Taking one fix at a time leaves ruff to decide what is\n // applicable against the current content, rather than reproducing how it\n // batches, orders and skips overlapping fixes within a pass.\n for (let i = 0; i < MAX_FIX_ITERATIONS; i++) {\n let diagnostic: Diagnostic | undefined;\n try {\n diagnostic = (workspace.check(content) as Diagnostic[]).find(\n (d) => d.fix && d.fix.edits.length > 0,\n );\n } catch {\n // Content that does not parse has nothing to fix; still try to format it.\n break;\n }\n if (!diagnostic?.fix) {\n break;\n }\n const fixed = applyFix(content, diagnostic.fix.edits);\n if (fixed === content) {\n break;\n }\n content = fixed;\n }\n\n try {\n return workspace.format(content);\n } catch {\n // Leave content the formatter rejects (eg a syntax error) as-is.\n return content;\n }\n};\n"],"names":["PositionEncoding","Workspace","path","FIXABLE_RULES","MAX_FIX_ITERATIONS","RUFF_WASM_VERSION","version","applyFix","content","edits","lineStarts","i","length","push","offsetOf","location","row","column","result","end","edit","sort","a","b","start","slice","end_location","isInitPy","filePath","basename","_workspaces","Map","getWorkspace","options","key","JSON","stringify","workspace","get","Utf16","set","ruffFixAndFormat","lint","fixable","unfixable","diagnostic","check","find","d","fix","fixed","format"],"mappings":"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"}
|
package/src/utils/toml.d.ts
CHANGED
|
@@ -12,3 +12,8 @@ export declare const updateToml: (tree: Tree, filePath: string, updater: (prev:
|
|
|
12
12
|
* Read a toml file
|
|
13
13
|
*/
|
|
14
14
|
export declare const readToml: (tree: Tree, filePath: string) => TOML.JsonMap;
|
|
15
|
+
/**
|
|
16
|
+
* Read a toml file, treating one that is missing or cannot be parsed as absent.
|
|
17
|
+
* For callers that probe for optional configuration rather than requiring it.
|
|
18
|
+
*/
|
|
19
|
+
export declare const tryReadToml: (tree: Tree, filePath: string) => TOML.JsonMap | undefined;
|
package/src/utils/toml.js
CHANGED
|
@@ -16,5 +16,15 @@
|
|
|
16
16
|
}
|
|
17
17
|
return TOML.parse(tree.read(filePath, 'utf-8'));
|
|
18
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* Read a toml file, treating one that is missing or cannot be parsed as absent.
|
|
21
|
+
* For callers that probe for optional configuration rather than requiring it.
|
|
22
|
+
*/ export const tryReadToml = (tree, filePath)=>{
|
|
23
|
+
try {
|
|
24
|
+
return readToml(tree, filePath);
|
|
25
|
+
} catch {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
19
29
|
|
|
20
30
|
//# sourceMappingURL=toml.js.map
|
package/src/utils/toml.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/toml.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport TOML from '@iarna/toml';\nimport type { Tree } from '@nx/devkit';\n\n/**\n * Update a toml file\n */\nexport const updateToml = (\n tree: Tree,\n filePath: string,\n updater: (prev: TOML.JsonMap) => TOML.JsonMap,\n) => {\n const prev = readToml(tree, filePath);\n tree.write(filePath, TOML.stringify(updater(prev)));\n};\n\n/**\n * Read a toml file\n */\nexport const readToml = (tree: Tree, filePath: string): TOML.JsonMap => {\n if (!tree.exists(filePath)) {\n throw new Error(`${filePath} does not exist`);\n }\n return TOML.parse(tree.read(filePath, 'utf-8'));\n};\n"],"names":["TOML","updateToml","tree","filePath","updater","prev","readToml","write","stringify","exists","Error","parse","read"],"mappings":"AAAA;;;CAGC,GAED,OAAOA,UAAU,cAAc;AAG/B;;CAEC,GACD,OAAO,MAAMC,aAAa,CACxBC,MACAC,UACAC;IAEA,MAAMC,OAAOC,SAASJ,MAAMC;IAC5BD,KAAKK,KAAK,CAACJ,UAAUH,KAAKQ,SAAS,CAACJ,QAAQC;AAC9C,EAAE;AAEF;;CAEC,GACD,OAAO,MAAMC,WAAW,CAACJ,MAAYC;IACnC,IAAI,CAACD,KAAKO,MAAM,CAACN,WAAW;QAC1B,MAAM,IAAIO,MAAM,GAAGP,SAAS,eAAe,CAAC;IAC9C;IACA,OAAOH,KAAKW,KAAK,CAACT,KAAKU,IAAI,CAACT,UAAU;AACxC,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/toml.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport TOML from '@iarna/toml';\nimport type { Tree } from '@nx/devkit';\n\n/**\n * Update a toml file\n */\nexport const updateToml = (\n tree: Tree,\n filePath: string,\n updater: (prev: TOML.JsonMap) => TOML.JsonMap,\n) => {\n const prev = readToml(tree, filePath);\n tree.write(filePath, TOML.stringify(updater(prev)));\n};\n\n/**\n * Read a toml file\n */\nexport const readToml = (tree: Tree, filePath: string): TOML.JsonMap => {\n if (!tree.exists(filePath)) {\n throw new Error(`${filePath} does not exist`);\n }\n return TOML.parse(tree.read(filePath, 'utf-8'));\n};\n\n/**\n * Read a toml file, treating one that is missing or cannot be parsed as absent.\n * For callers that probe for optional configuration rather than requiring it.\n */\nexport const tryReadToml = (\n tree: Tree,\n filePath: string,\n): TOML.JsonMap | undefined => {\n try {\n return readToml(tree, filePath);\n } catch {\n return undefined;\n }\n};\n"],"names":["TOML","updateToml","tree","filePath","updater","prev","readToml","write","stringify","exists","Error","parse","read","tryReadToml","undefined"],"mappings":"AAAA;;;CAGC,GAED,OAAOA,UAAU,cAAc;AAG/B;;CAEC,GACD,OAAO,MAAMC,aAAa,CACxBC,MACAC,UACAC;IAEA,MAAMC,OAAOC,SAASJ,MAAMC;IAC5BD,KAAKK,KAAK,CAACJ,UAAUH,KAAKQ,SAAS,CAACJ,QAAQC;AAC9C,EAAE;AAEF;;CAEC,GACD,OAAO,MAAMC,WAAW,CAACJ,MAAYC;IACnC,IAAI,CAACD,KAAKO,MAAM,CAACN,WAAW;QAC1B,MAAM,IAAIO,MAAM,GAAGP,SAAS,eAAe,CAAC;IAC9C;IACA,OAAOH,KAAKW,KAAK,CAACT,KAAKU,IAAI,CAACT,UAAU;AACxC,EAAE;AAEF;;;CAGC,GACD,OAAO,MAAMU,cAAc,CACzBX,MACAC;IAEA,IAAI;QACF,OAAOG,SAASJ,MAAMC;IACxB,EAAE,OAAM;QACN,OAAOW;IACT;AACF,EAAE"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Vitest globalSetup that warms uv's tool cache once before any worker spawns,
|
|
3
|
-
* installing the exact pinned ruff the formatter runs. On a cold cache the
|
|
4
|
-
* first uvx call holds an exclusive lock on uv's cache, so parallel workers
|
|
5
|
-
* would otherwise stall racing it. Failure is ignored — the formatter skips
|
|
6
|
-
* ruff when uv is unavailable.
|
|
7
|
-
*/
|
|
8
|
-
export default function setup(): void;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/ import { execFileSync } from "child_process";
|
|
5
|
-
import { withPyVersions } from "./versions.js";
|
|
6
|
-
/**
|
|
7
|
-
* Vitest globalSetup that warms uv's tool cache once before any worker spawns,
|
|
8
|
-
* installing the exact pinned ruff the formatter runs. On a cold cache the
|
|
9
|
-
* first uvx call holds an exclusive lock on uv's cache, so parallel workers
|
|
10
|
-
* would otherwise stall racing it. Failure is ignored — the formatter skips
|
|
11
|
-
* ruff when uv is unavailable.
|
|
12
|
-
*/ export default function setup() {
|
|
13
|
-
const ruff = withPyVersions([
|
|
14
|
-
'ruff'
|
|
15
|
-
])[0];
|
|
16
|
-
try {
|
|
17
|
-
execFileSync('uvx', [
|
|
18
|
-
'--from',
|
|
19
|
-
ruff,
|
|
20
|
-
'ruff',
|
|
21
|
-
'--version'
|
|
22
|
-
], {
|
|
23
|
-
stdio: 'ignore'
|
|
24
|
-
});
|
|
25
|
-
} catch {
|
|
26
|
-
// Ignore — the formatter skips ruff when it is unavailable
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
//# sourceMappingURL=warm-ruff-cache.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/warm-ruff-cache.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { execFileSync } from 'child_process';\nimport { withPyVersions } from './versions';\n\n/**\n * Vitest globalSetup that warms uv's tool cache once before any worker spawns,\n * installing the exact pinned ruff the formatter runs. On a cold cache the\n * first uvx call holds an exclusive lock on uv's cache, so parallel workers\n * would otherwise stall racing it. Failure is ignored — the formatter skips\n * ruff when uv is unavailable.\n */\nexport default function setup() {\n const ruff = withPyVersions(['ruff'])[0];\n try {\n execFileSync('uvx', ['--from', ruff, 'ruff', '--version'], {\n stdio: 'ignore',\n });\n } catch {\n // Ignore — the formatter skips ruff when it is unavailable\n }\n}\n"],"names":["execFileSync","withPyVersions","setup","ruff","stdio"],"mappings":"AAAA;;;CAGC,GACD,SAASA,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,cAAc,QAAQ,gBAAa;AAE5C;;;;;;CAMC,GACD,eAAe,SAASC;IACtB,MAAMC,OAAOF,eAAe;QAAC;KAAO,CAAC,CAAC,EAAE;IACxC,IAAI;QACFD,aAAa,OAAO;YAAC;YAAUG;YAAM;YAAQ;SAAY,EAAE;YACzDC,OAAO;QACT;IACF,EAAE,OAAM;IACN,2DAA2D;IAC7D;AACF"}
|