@aws/nx-plugin 0.90.0 → 0.91.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/generators.json +8 -0
- package/package.json +1 -1
- package/src/connection/generator.d.ts +2 -2
- package/src/connection/generator.js +19 -16
- package/src/connection/generator.js.map +1 -1
- package/src/mcp-server/generator-info.d.ts +8 -4
- package/src/mcp-server/generator-info.js +63 -15
- package/src/mcp-server/generator-info.js.map +1 -1
- package/src/preset/__snapshots__/generator.spec.ts.snap +1 -3
- package/src/ts/nx-generator/generator.d.ts +1 -1
- package/src/ts/react-website/runtime-config/__snapshots__/generator.spec.ts.snap +3 -1
- package/src/ts/react-website/runtime-config/files/app/components/RuntimeConfig/index.tsx.template +1 -1
- package/src/ts/strands-agent/react-connection/__snapshots__/generator.spec.ts.snap +376 -0
- package/src/ts/strands-agent/react-connection/files/src/components/__agentNameClassName__AgentClientProvider.tsx.template +117 -0
- package/src/ts/strands-agent/react-connection/files/src/hooks/use__agentNameClassName__Agent.tsx.template +18 -0
- package/src/ts/strands-agent/react-connection/generator.d.ts +10 -0
- package/src/ts/strands-agent/react-connection/generator.js +129 -0
- package/src/ts/strands-agent/react-connection/generator.js.map +1 -0
- package/src/ts/strands-agent/react-connection/schema.d.ts +15 -0
- package/src/ts/strands-agent/react-connection/schema.json +26 -0
- package/src/ts/strands-agent/react-connection/serve-local.d.ts +17 -0
- package/src/ts/strands-agent/react-connection/serve-local.js +45 -0
- package/src/ts/strands-agent/react-connection/serve-local.js.map +1 -0
- package/src/utils/ast.d.ts +3 -23
- package/src/utils/ast.js +21 -152
- package/src/utils/ast.js.map +1 -1
- package/src/utils/commands.d.ts +33 -0
- package/src/utils/commands.js +55 -0
- package/src/utils/commands.js.map +1 -0
- package/src/utils/config/__snapshots__/utils.spec.ts.snap +88 -0
- package/src/utils/config/utils.d.ts +2 -1
- package/src/utils/config/utils.js +47 -29
- package/src/utils/config/utils.js.map +1 -1
- package/src/utils/generators.d.ts +13 -0
- package/src/utils/generators.js +26 -0
- package/src/utils/generators.js.map +1 -0
- package/src/utils/nx.d.ts +4 -10
- package/src/utils/nx.js +5 -19
- package/src/utils/nx.js.map +1 -1
- package/src/utils/pkg-manager.d.ts +2 -22
- package/src/utils/pkg-manager.js +2 -7
- package/src/utils/pkg-manager.js.map +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "ts#strands-agent#react-connection",
|
|
4
|
+
"title": "ts#strands-agent#react-connection",
|
|
5
|
+
"description": "Connect a React website to a TypeScript Strands Agent",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"sourceProject": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "The React website project"
|
|
11
|
+
},
|
|
12
|
+
"targetProject": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"description": "The project containing the Strands Agent"
|
|
15
|
+
},
|
|
16
|
+
"sourceComponent": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "The source component name"
|
|
19
|
+
},
|
|
20
|
+
"targetComponent": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "The Strands Agent component name"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"required": ["sourceProject", "targetProject"]
|
|
26
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { Tree } from '@nx/devkit';
|
|
6
|
+
import { ComponentMetadata } from '../../../utils/nx';
|
|
7
|
+
export interface StrandsAgentServeLocalOptions {
|
|
8
|
+
agentName: string;
|
|
9
|
+
agentNameClassName: string;
|
|
10
|
+
port: number;
|
|
11
|
+
targetComponent?: ComponentMetadata;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Adds the given strands agent target project to the source project's serve-local target
|
|
15
|
+
* Updates the runtime config provider (if it exists) to point to the local WebSocket URL
|
|
16
|
+
*/
|
|
17
|
+
export declare const addStrandsAgentTargetToServeLocal: (tree: Tree, sourceProjectName: string, targetProjectName: string, options: StrandsAgentServeLocalOptions) => Promise<void>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addStrandsAgentTargetToServeLocal = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
6
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
7
|
+
*/
|
|
8
|
+
const devkit_1 = require("@nx/devkit");
|
|
9
|
+
const ast_1 = require("../../../utils/ast");
|
|
10
|
+
const nx_1 = require("../../../utils/nx");
|
|
11
|
+
/**
|
|
12
|
+
* Adds the given strands agent target project to the source project's serve-local target
|
|
13
|
+
* Updates the runtime config provider (if it exists) to point to the local WebSocket URL
|
|
14
|
+
*/
|
|
15
|
+
const addStrandsAgentTargetToServeLocal = async (tree, sourceProjectName, targetProjectName, options) => {
|
|
16
|
+
const sourceProject = (0, nx_1.readProjectConfigurationUnqualified)(tree, sourceProjectName);
|
|
17
|
+
const targetProject = (0, nx_1.readProjectConfigurationUnqualified)(tree, targetProjectName);
|
|
18
|
+
// Determine the serve-local target name for the agent component
|
|
19
|
+
const agentServeLocalTargetName = options.targetComponent?.name
|
|
20
|
+
? `${options.targetComponent.name}-serve-local`
|
|
21
|
+
: 'agent-serve-local';
|
|
22
|
+
// Target project must have the agent serve-local target which is continuous
|
|
23
|
+
if (!(targetProject.targets?.[agentServeLocalTargetName]?.continuous &&
|
|
24
|
+
sourceProject.targets?.['serve-local'])) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
// Add a dependency on the agent serve-local target (so that the agent's
|
|
28
|
+
// own serve-local dependencies, such as MCP servers, are also started)
|
|
29
|
+
sourceProject.targets['serve-local'].dependsOn = [
|
|
30
|
+
...(sourceProject.targets['serve-local'].dependsOn ?? []),
|
|
31
|
+
{
|
|
32
|
+
projects: [targetProject.name],
|
|
33
|
+
target: agentServeLocalTargetName,
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
(0, devkit_1.updateProjectConfiguration)(tree, sourceProject.name, sourceProject);
|
|
37
|
+
// Add an override to runtime-config for the serve-local target to use the local WebSocket url
|
|
38
|
+
const runtimeConfigProvider = (0, devkit_1.joinPathFragments)(sourceProject.root, 'src', 'components', 'RuntimeConfig', 'index.tsx');
|
|
39
|
+
if (tree.exists(runtimeConfigProvider)) {
|
|
40
|
+
const localUrl = `ws://localhost:${options.port}/ws`;
|
|
41
|
+
await (0, ast_1.applyGritQL)(tree, runtimeConfigProvider, `\`if ($cond) { $stmts }\` => raw\`if ($cond) {\n $stmts\n runtimeConfig.agentRuntimes.${options.agentNameClassName} = '${localUrl}';\n }\` where { $cond <: contains \`'serve-local'\`, $stmts <: within \`const applyOverrides = $_\` }`);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
exports.addStrandsAgentTargetToServeLocal = addStrandsAgentTargetToServeLocal;
|
|
45
|
+
//# sourceMappingURL=serve-local.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serve-local.js","sourceRoot":"","sources":["../../../../../../../packages/nx-plugin/src/ts/strands-agent/react-connection/serve-local.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uCAIoB;AACpB,4CAAiD;AACjD,0CAG2B;AAS3B;;;GAGG;AACI,MAAM,iCAAiC,GAAG,KAAK,EACpD,IAAU,EACV,iBAAyB,EACzB,iBAAyB,EACzB,OAAsC,EACtC,EAAE;IACF,MAAM,aAAa,GAAG,IAAA,wCAAmC,EACvD,IAAI,EACJ,iBAAiB,CAClB,CAAC;IACF,MAAM,aAAa,GAAG,IAAA,wCAAmC,EACvD,IAAI,EACJ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
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
import { Tree } from '@nx/devkit';
|
|
6
|
-
import ts, { JsxChild, JsxClosingElement, JsxOpeningElement, Node } from 'typescript';
|
|
7
6
|
export declare const addDestructuredImport: (tree: Tree, filePath: string, variableNames: string[], from: string) => Promise<void>;
|
|
8
7
|
/**
|
|
9
8
|
* Adds an `import <variableName> from '<from>'; statement to the beginning of the file,
|
|
@@ -16,29 +15,10 @@ export declare const addSingleImport: (tree: Tree, filePath: string, variableNam
|
|
|
16
15
|
*/
|
|
17
16
|
export declare const addStarExport: (tree: Tree, filePath: string, from: string) => Promise<void>;
|
|
18
17
|
/**
|
|
19
|
-
*
|
|
18
|
+
* Return whether or not the given identifier is exported in the source file.
|
|
19
|
+
* Checks for both `export { Identifier }` and `export type Identifier = ...`.
|
|
20
20
|
*/
|
|
21
|
-
export declare const
|
|
22
|
-
/**
|
|
23
|
-
* Replace nodes matching a given selector if present, otherwise leaves the code unchanged
|
|
24
|
-
*/
|
|
25
|
-
export declare const replaceIfExists: (tree: Tree, filePath: string, selector: string, transformer: (node: Node) => Node) => void;
|
|
26
|
-
export declare const prependStatements: (tree: Tree, filePath: string, statements: ts.Statement[]) => void;
|
|
27
|
-
export declare const appendStatements: (tree: Tree, filePath: string, statements: ts.Statement[]) => void;
|
|
28
|
-
/**
|
|
29
|
-
* Query a typescript file in the tree using tsquery
|
|
30
|
-
*/
|
|
31
|
-
export declare const query: (tree: Tree, filePath: string, selector: string) => Node[];
|
|
32
|
-
export declare const createJsxElementFromIdentifier: (identifier: string, children: readonly JsxChild[]) => ts.JsxElement;
|
|
33
|
-
export declare const createJsxElement: (openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement) => ts.JsxElement;
|
|
34
|
-
/**
|
|
35
|
-
* Convert a given json object to its AST representation
|
|
36
|
-
*/
|
|
37
|
-
export declare const jsonToAst: (obj: unknown) => Node;
|
|
38
|
-
/**
|
|
39
|
-
* Return whether or not the given identifier is exported in the source file
|
|
40
|
-
*/
|
|
41
|
-
export declare const hasExportDeclaration: (source: string, identifierName: string) => boolean;
|
|
21
|
+
export declare const hasExportDeclaration: (source: string, identifierName: string) => Promise<boolean>;
|
|
42
22
|
/**
|
|
43
23
|
* Apply a GritQL pattern to a file in the Nx tree.
|
|
44
24
|
*/
|
package/src/utils/ast.js
CHANGED
|
@@ -1,30 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.matchGritQL = exports.applyGritQL = exports.hasExportDeclaration = exports.
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
6
|
-
const typescript_1 = tslib_1.__importStar(require("typescript"));
|
|
3
|
+
exports.matchGritQL = exports.applyGritQL = exports.hasExportDeclaration = exports.addStarExport = exports.addSingleImport = exports.addDestructuredImport = void 0;
|
|
7
4
|
const gritql_1 = require("@getgrit/gritql");
|
|
8
5
|
const assertFilePath = (tree, filePath) => {
|
|
9
6
|
if (!tree.exists(filePath)) {
|
|
10
7
|
throw new Error(`No file located at ${filePath}`);
|
|
11
8
|
}
|
|
12
9
|
};
|
|
13
|
-
const updateFile = (tree, filePath, doUpdate) => {
|
|
14
|
-
assertFilePath(tree, filePath);
|
|
15
|
-
const contents = tree.read(filePath)?.toString() ?? '';
|
|
16
|
-
const updatedContents = doUpdate(contents);
|
|
17
|
-
if (updatedContents !== contents) {
|
|
18
|
-
tree.write(filePath, updatedContents);
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
const createOrUpdateFile = (tree, filePath, doUpdate) => {
|
|
22
|
-
const contents = tree.read(filePath)?.toString();
|
|
23
|
-
const updatedContents = doUpdate(contents);
|
|
24
|
-
if (updatedContents !== contents) {
|
|
25
|
-
tree.write(filePath, updatedContents);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
10
|
const addDestructuredImport = async (tree, filePath, variableNames, from) => {
|
|
29
11
|
assertFilePath(tree, filePath);
|
|
30
12
|
// Check if there's an existing import from this module
|
|
@@ -84,143 +66,30 @@ const addStarExport = async (tree, filePath, from) => {
|
|
|
84
66
|
};
|
|
85
67
|
exports.addStarExport = addStarExport;
|
|
86
68
|
/**
|
|
87
|
-
*
|
|
69
|
+
* Return whether or not the given identifier is exported in the source file.
|
|
70
|
+
* Checks for both `export { Identifier }` and `export type Identifier = ...`.
|
|
88
71
|
*/
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
exports.replace = replace;
|
|
104
|
-
/**
|
|
105
|
-
* Replace nodes matching a given selector if present, otherwise leaves the code unchanged
|
|
106
|
-
*/
|
|
107
|
-
const replaceIfExists = (tree, filePath, selector, transformer) => (0, exports.replace)(tree, filePath, selector, transformer, false);
|
|
108
|
-
exports.replaceIfExists = replaceIfExists;
|
|
109
|
-
/**
|
|
110
|
-
* Apply a transform to the given code using the transformer.
|
|
111
|
-
* Equivalent to tsquery.map, except that this preserves existing code formatting where possible
|
|
112
|
-
*/
|
|
113
|
-
const applyTransform = (code, selector, transformer) => {
|
|
114
|
-
const sourceFile = (0, tsquery_1.ast)(code);
|
|
115
|
-
const transforms = [];
|
|
116
|
-
const printer = typescript_1.default.createPrinter({
|
|
117
|
-
removeComments: true,
|
|
118
|
-
});
|
|
119
|
-
tsquery_1.tsquery.map(sourceFile, selector, (node) => {
|
|
120
|
-
const newNode = transformer(node);
|
|
121
|
-
if (newNode !== node && newNode) {
|
|
122
|
-
transforms.push({
|
|
123
|
-
start: node.getStart(sourceFile, true),
|
|
124
|
-
end: node.getEnd(),
|
|
125
|
-
newText: printer.printNode(typescript_1.default.EmitHint.Unspecified, newNode, sourceFile),
|
|
72
|
+
const hasExportDeclaration = async (source, identifierName) => {
|
|
73
|
+
const patterns = [
|
|
74
|
+
`\`export type ${identifierName} = $_\``,
|
|
75
|
+
`\`export { ${identifierName} }\``,
|
|
76
|
+
`\`export type { ${identifierName} } from $_\``,
|
|
77
|
+
];
|
|
78
|
+
for (const pattern of patterns) {
|
|
79
|
+
try {
|
|
80
|
+
const q = new gritql_1.QueryBuilder(`$p => $p where { $p <: ${pattern} }`);
|
|
81
|
+
const result = await q.applyToFile({
|
|
82
|
+
path: 'check.ts',
|
|
83
|
+
content: source,
|
|
126
84
|
});
|
|
85
|
+
if (result !== null)
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
// Pattern didn't match, try next
|
|
127
90
|
}
|
|
128
|
-
return newNode;
|
|
129
|
-
});
|
|
130
|
-
let newCode = code;
|
|
131
|
-
let offset = 0;
|
|
132
|
-
transforms.forEach((transform) => {
|
|
133
|
-
newCode =
|
|
134
|
-
newCode.substring(0, transform.start + offset) +
|
|
135
|
-
transform.newText +
|
|
136
|
-
newCode.substring(transform.end + offset);
|
|
137
|
-
offset = newCode.length - code.length;
|
|
138
|
-
});
|
|
139
|
-
return newCode;
|
|
140
|
-
};
|
|
141
|
-
const insertStatements = (isPrepend, code, statements) => {
|
|
142
|
-
const sourceFile = (0, tsquery_1.ast)(code);
|
|
143
|
-
const printer = typescript_1.default.createPrinter();
|
|
144
|
-
const newText = statements
|
|
145
|
-
.map((s) => printer.printNode(typescript_1.default.EmitHint.Unspecified, s, sourceFile))
|
|
146
|
-
.join('\n');
|
|
147
|
-
if (isPrepend) {
|
|
148
|
-
return newText + '\n' + code;
|
|
149
|
-
}
|
|
150
|
-
return code + '\n' + newText;
|
|
151
|
-
};
|
|
152
|
-
const appendStatementsToCodeText = (code, statements) => {
|
|
153
|
-
return insertStatements(false, code, statements);
|
|
154
|
-
};
|
|
155
|
-
const prependStatementsToCodeText = (code, statements) => {
|
|
156
|
-
return insertStatements(true, code, statements);
|
|
157
|
-
};
|
|
158
|
-
const prependStatements = (tree, filePath, statements) => {
|
|
159
|
-
updateFile(tree, filePath, (contents) => {
|
|
160
|
-
return prependStatementsToCodeText(contents, statements);
|
|
161
|
-
});
|
|
162
|
-
};
|
|
163
|
-
exports.prependStatements = prependStatements;
|
|
164
|
-
const appendStatements = (tree, filePath, statements) => {
|
|
165
|
-
updateFile(tree, filePath, (contents) => {
|
|
166
|
-
return appendStatementsToCodeText(contents, statements);
|
|
167
|
-
});
|
|
168
|
-
};
|
|
169
|
-
exports.appendStatements = appendStatements;
|
|
170
|
-
/**
|
|
171
|
-
* Query a typescript file in the tree using tsquery
|
|
172
|
-
*/
|
|
173
|
-
const query = (tree, filePath, selector) => {
|
|
174
|
-
assertFilePath(tree, filePath);
|
|
175
|
-
const source = tree.read(filePath).toString();
|
|
176
|
-
return tsquery_1.tsquery.query((0, tsquery_1.ast)(source), selector);
|
|
177
|
-
};
|
|
178
|
-
exports.query = query;
|
|
179
|
-
const createJsxElementFromIdentifier = (identifier, children) => typescript_1.factory.createJsxElement(typescript_1.factory.createJsxOpeningElement(typescript_1.factory.createIdentifier(identifier), undefined, typescript_1.factory.createJsxAttributes([])), children, typescript_1.factory.createJsxClosingElement(typescript_1.factory.createIdentifier(identifier)));
|
|
180
|
-
exports.createJsxElementFromIdentifier = createJsxElementFromIdentifier;
|
|
181
|
-
const createJsxElement = (openingElement, children, closingElement) => typescript_1.factory.createJsxElement(openingElement, children, closingElement);
|
|
182
|
-
exports.createJsxElement = createJsxElement;
|
|
183
|
-
/**
|
|
184
|
-
* Convert a given json object to its AST representation
|
|
185
|
-
*/
|
|
186
|
-
const jsonToAst = (obj) => {
|
|
187
|
-
if (obj === null) {
|
|
188
|
-
return typescript_1.factory.createNull();
|
|
189
|
-
}
|
|
190
|
-
if (obj === undefined) {
|
|
191
|
-
return typescript_1.factory.createIdentifier('undefined');
|
|
192
|
-
}
|
|
193
|
-
if (typeof obj === 'string') {
|
|
194
|
-
return typescript_1.factory.createStringLiteral(obj);
|
|
195
|
-
}
|
|
196
|
-
if (typeof obj === 'number') {
|
|
197
|
-
return typescript_1.factory.createNumericLiteral(obj);
|
|
198
|
-
}
|
|
199
|
-
if (typeof obj === 'boolean') {
|
|
200
|
-
return obj ? typescript_1.factory.createTrue() : typescript_1.factory.createFalse();
|
|
201
|
-
}
|
|
202
|
-
if (Array.isArray(obj)) {
|
|
203
|
-
return typescript_1.factory.createArrayLiteralExpression(obj.map((item) => (0, exports.jsonToAst)(item)));
|
|
204
|
-
}
|
|
205
|
-
if (typeof obj === 'object') {
|
|
206
|
-
return typescript_1.factory.createObjectLiteralExpression(Object.entries(obj).map(([key, value]) => {
|
|
207
|
-
// Check if the key is a valid identifier
|
|
208
|
-
const isValidIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key);
|
|
209
|
-
return typescript_1.factory.createPropertyAssignment(isValidIdentifier
|
|
210
|
-
? typescript_1.factory.createIdentifier(key)
|
|
211
|
-
: typescript_1.factory.createStringLiteral(key), (0, exports.jsonToAst)(value));
|
|
212
|
-
}));
|
|
213
91
|
}
|
|
214
|
-
|
|
215
|
-
};
|
|
216
|
-
exports.jsonToAst = jsonToAst;
|
|
217
|
-
/**
|
|
218
|
-
* Return whether or not the given identifier is exported in the source file
|
|
219
|
-
*/
|
|
220
|
-
const hasExportDeclaration = (source, identifierName) => {
|
|
221
|
-
const sourceFile = (0, tsquery_1.ast)(source);
|
|
222
|
-
return (tsquery_1.tsquery.query(sourceFile, `ExportDeclaration:has(ExportSpecifier:has(Identifier[name="${identifierName}"]))`).length > 0 ||
|
|
223
|
-
tsquery_1.tsquery.query(sourceFile, `TypeAliasDeclaration:has(ExportKeyword):has(Identifier[name="${identifierName}"])`).length > 0);
|
|
92
|
+
return false;
|
|
224
93
|
};
|
|
225
94
|
exports.hasExportDeclaration = hasExportDeclaration;
|
|
226
95
|
/**
|
package/src/utils/ast.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast.js","sourceRoot":"","sources":["../../../../../packages/nx-plugin/src/utils/ast.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ast.js","sourceRoot":"","sources":["../../../../../packages/nx-plugin/src/utils/ast.ts"],"names":[],"mappings":";;;AAKA,4CAA+C;AAE/C,MAAM,cAAc,GAAG,CAAC,IAAU,EAAE,QAAgB,EAAE,EAAE;IACtD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,sBAAsB,QAAQ,EAAE,CAAC,CAAC;IACpD,CAAC;AACH,CAAC,CAAC;AAEK,MAAM,qBAAqB,GAAG,KAAK,EACxC,IAAU,EACV,QAAgB,EAChB,aAAuB,EACvB,IAAY,EACZ,EAAE;IACF,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAE/B,uDAAuD;IACvD,MAAM,iBAAiB,GAAG,MAAM,IAAA,mBAAW,EACzC,IAAI,EACJ,QAAQ,EACR,yBAAyB,IAAI,KAAK,CACnC,CAAC;IAEF,IAAI,iBAAiB,EAAE,CAAC;QACtB,6EAA6E;QAC7E,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE,CAAC;YACzC,MAAM,SAAS,GAAG,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC;gBAC7C,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBAC/B,CAAC,CAAC,YAAY,CAAC;YACjB,kFAAkF;YAClF,MAAM,IAAA,mBAAW,EACf,IAAI,EACJ,QAAQ,EACR,+BAA+B,IAAI,+BAA+B,YAAY,YAAY,IAAI,0CAA0C,SAAS,MAAM,CACxJ,CAAC;QACJ,CAAC;IACH,CAAC;SAAM,CAAC;QACN,yCAAyC;QACzC,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI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AAC,CAAC;IACxC,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IAC5E,IAAI,MAAM,IAAI,MAAM,CAAC,OAAO,KAAK,MAAM,EAAE,CAAC;QACxC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAdW,QAAA,WAAW,eActB;AAEF;;;GAGG;AACI,MAAM,WAAW,GAAG,KAAK,EAC9B,IAAU,EACV,QAAgB,EAChB,OAAe,EACG,EAAE;IACpB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;QAAE,OAAO,KAAK,CAAC;IACzC,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAE,CAAC,QAAQ,EAAE,CAAC;IAC/C,IAAI,CAAC;QACH,yEAAyE;QACzE,uEAAuE;QACvE,qCAAqC;QACrC,MAAM,KAAK,GAAG,IAAI,qBAAY,CAAC,0BAA0B,OAAO,IAAI,CAAC,CAAC;QACtE,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,WAAW,CAAC;YACrC,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,MAAM;SAChB,CAAC,CAAC;QACH,OAAO,MAAM,KAAK,IAAI,CAAC;IACzB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC;AApBW,QAAA,WAAW,eAoBtB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display-friendly command prefixes for each package manager.
|
|
3
|
+
*
|
|
4
|
+
* - `exec`: prefix for running local binaries (e.g. `npx nx`, `pnpm nx`, `bunx nx`)
|
|
5
|
+
* - `run`: prefix for running package.json scripts (e.g. `npm run build`, `pnpm build`)
|
|
6
|
+
*
|
|
7
|
+
* @see docs/src/components/package-manager-exec-command.astro
|
|
8
|
+
* @see docs/src/components/package-manager-short-command.astro
|
|
9
|
+
*/
|
|
10
|
+
export interface PackageManagerDisplayCommands {
|
|
11
|
+
/** Prefix for running local binaries: npx, pnpm, yarn, bunx */
|
|
12
|
+
exec: string;
|
|
13
|
+
/** Prefix for running package.json scripts: `npm run`, pnpm, yarn, bun */
|
|
14
|
+
run: string;
|
|
15
|
+
}
|
|
16
|
+
export declare const PACKAGE_MANAGER_COMMANDS: Record<string, PackageManagerDisplayCommands>;
|
|
17
|
+
/**
|
|
18
|
+
* Build a package manager exec command (e.g. pnpm cmd, npx cmd, bunx cmd)
|
|
19
|
+
*/
|
|
20
|
+
export declare const buildPackageManagerExecCommand: (pm: string, command: string) => string;
|
|
21
|
+
/**
|
|
22
|
+
* Build a short package manager command (e.g. pnpm build, npm run build)
|
|
23
|
+
*/
|
|
24
|
+
export declare const buildPackageManagerShortCommand: (pm: string, command: string) => string;
|
|
25
|
+
/**
|
|
26
|
+
* Build an install command for a given package manager
|
|
27
|
+
*/
|
|
28
|
+
export declare const buildInstallCommand: (pm: string, pkg: string, dev: boolean) => string;
|
|
29
|
+
/**
|
|
30
|
+
* Build a create-nx-workspace command.
|
|
31
|
+
* Defaults to the pinned create-nx-workspace version from TS_VERSIONS.
|
|
32
|
+
*/
|
|
33
|
+
export declare const buildCreateNxWorkspaceCommand: (pm: string, workspace: string, iacProvider?: "CDK" | "Terraform", yes?: boolean, nxVersion?: string, nxPluginVersion?: string) => string;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildCreateNxWorkspaceCommand = exports.buildInstallCommand = exports.buildPackageManagerShortCommand = exports.buildPackageManagerExecCommand = exports.PACKAGE_MANAGER_COMMANDS = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
6
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
7
|
+
*/
|
|
8
|
+
const versions_1 = require("./versions");
|
|
9
|
+
exports.PACKAGE_MANAGER_COMMANDS = {
|
|
10
|
+
npm: { exec: 'npx', run: 'npm run' },
|
|
11
|
+
pnpm: { exec: 'pnpm', run: 'pnpm' },
|
|
12
|
+
yarn: { exec: 'yarn', run: 'yarn' },
|
|
13
|
+
bun: { exec: 'bunx', run: 'bun' },
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Build a package manager exec command (e.g. pnpm cmd, npx cmd, bunx cmd)
|
|
17
|
+
*/
|
|
18
|
+
const buildPackageManagerExecCommand = (pm, command) => {
|
|
19
|
+
const prefix = exports.PACKAGE_MANAGER_COMMANDS[pm]?.exec ?? pm;
|
|
20
|
+
return `${prefix} ${command}`;
|
|
21
|
+
};
|
|
22
|
+
exports.buildPackageManagerExecCommand = buildPackageManagerExecCommand;
|
|
23
|
+
/**
|
|
24
|
+
* Build a short package manager command (e.g. pnpm build, npm run build)
|
|
25
|
+
*/
|
|
26
|
+
const buildPackageManagerShortCommand = (pm, command) => {
|
|
27
|
+
const prefix = exports.PACKAGE_MANAGER_COMMANDS[pm]?.run ?? pm;
|
|
28
|
+
return `${prefix} ${command}`;
|
|
29
|
+
};
|
|
30
|
+
exports.buildPackageManagerShortCommand = buildPackageManagerShortCommand;
|
|
31
|
+
/**
|
|
32
|
+
* Build an install command for a given package manager
|
|
33
|
+
*/
|
|
34
|
+
const buildInstallCommand = (pm, pkg, dev) => {
|
|
35
|
+
switch (pm) {
|
|
36
|
+
case 'pnpm':
|
|
37
|
+
return `pnpm add ${dev ? '-D' : '-'}w ${pkg}`;
|
|
38
|
+
case 'yarn':
|
|
39
|
+
return `yarn add ${dev ? '-D ' : ''}${pkg}`;
|
|
40
|
+
case 'npm':
|
|
41
|
+
return `npm install --legacy-peer-deps ${dev ? '-D ' : ''}${pkg}`;
|
|
42
|
+
case 'bun':
|
|
43
|
+
return `bun install ${dev ? '-D ' : ''}${pkg}`;
|
|
44
|
+
default:
|
|
45
|
+
return `${pm} install ${dev ? '-D ' : ''}${pkg}`;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
exports.buildInstallCommand = buildInstallCommand;
|
|
49
|
+
/**
|
|
50
|
+
* Build a create-nx-workspace command.
|
|
51
|
+
* Defaults to the pinned create-nx-workspace version from TS_VERSIONS.
|
|
52
|
+
*/
|
|
53
|
+
const buildCreateNxWorkspaceCommand = (pm, workspace, iacProvider, yes = false, nxVersion = versions_1.TS_VERSIONS['create-nx-workspace'], nxPluginVersion) => `npx ${yes ? '-y ' : ''}create-nx-workspace@${nxVersion} ${workspace} --pm=${pm} --preset=@aws/nx-plugin${nxPluginVersion ? `@${nxPluginVersion}` : ''}${iacProvider ? ` --iacProvider=${iacProvider}` : ''} --ci=skip --analytics=false --aiAgents`;
|
|
54
|
+
exports.buildCreateNxWorkspaceCommand = buildCreateNxWorkspaceCommand;
|
|
55
|
+
//# sourceMappingURL=commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../../../../packages/nx-plugin/src/utils/commands.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,yCAAyC;AAkB5B,QAAA,wBAAwB,GAGjC;IACF,GAAG,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE;IACpC,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE;IACnC,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE;IACnC,GAAG,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE;CAClC,CAAC;AAEF;;GAEG;AACI,MAAM,8BAA8B,GAAG,CAAC,EAAU,EAAE,OAAe,EAAE,EAAE;IAC5E,MAAM,MAA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jC,GAAG,GAAG,KAAK,EACX,YAAoB,sBAAW,CAAC,qBAAqB,CAAC,EACtD,eAAwB,EACxB,EAAE,CACF,OAAO,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,uBAAuB,SAAS,IAAI,SAAS,SAAS,EAAE,2BAA2B,eAAe,CAAC,CAAC,CAAC,IAAI,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,WAAW,CAAC,CAAC,CAAC,kBAAkB,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,yCAAyC,CAAC;AAR1O,QAAA,6BAA6B,iCAQ6M"}
|
|
@@ -1,5 +1,93 @@
|
|
|
1
1
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
2
|
|
|
3
|
+
exports[`config utils > should add multiple new keys to an empty config 1`] = `
|
|
4
|
+
"import { AwsNxPluginConfig } from '@aws/nx-plugin';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
iac: { provider: 'CDK' },
|
|
8
|
+
tags: ['a', 'b'],
|
|
9
|
+
} satisfies AwsNxPluginConfig;
|
|
10
|
+
"
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
exports[`config utils > should handle config with special characters in values 1`] = `
|
|
14
|
+
"import { AwsNxPluginConfig } from '@aws/nx-plugin';
|
|
15
|
+
|
|
16
|
+
export default {
|
|
17
|
+
license: {
|
|
18
|
+
header: {
|
|
19
|
+
content: { lines: ['Copyright "Foo" Inc.'] },
|
|
20
|
+
format: {
|
|
21
|
+
'**/*.{js,ts,jsx,tsx}': {
|
|
22
|
+
blockStart: '/**',
|
|
23
|
+
lineStart: ' * ',
|
|
24
|
+
blockEnd: ' */',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
} satisfies AwsNxPluginConfig;
|
|
30
|
+
"
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
exports[`config utils > should handle config without satisfies clause 1`] = `
|
|
34
|
+
"export default { iac: { provider: 'CDK' } };
|
|
35
|
+
"
|
|
36
|
+
`;
|
|
37
|
+
|
|
38
|
+
exports[`config utils > should preserve JS expressions when updating a different key 1`] = `
|
|
39
|
+
"import { AwsNxPluginConfig } from '@aws/nx-plugin';
|
|
40
|
+
|
|
41
|
+
export default {
|
|
42
|
+
license: {
|
|
43
|
+
header: {
|
|
44
|
+
content: { lines: [\`Copyright \${new Date().getFullYear()} Foo Inc.\`] },
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
iac: { provider: 'CDK' },
|
|
48
|
+
} satisfies AwsNxPluginConfig;
|
|
49
|
+
"
|
|
50
|
+
`;
|
|
51
|
+
|
|
52
|
+
exports[`config utils > should preserve JS expressions when updating an unrelated key alongside 1`] = `
|
|
53
|
+
"import { AwsNxPluginConfig } from '@aws/nx-plugin';
|
|
54
|
+
|
|
55
|
+
export default {
|
|
56
|
+
license: {
|
|
57
|
+
copyrightHolder: 'Acme',
|
|
58
|
+
header: {
|
|
59
|
+
content: { lines: [\`Copyright \${new Date().getFullYear()} Acme\`] },
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
iac: { provider: 'Terraform' },
|
|
63
|
+
} satisfies AwsNxPluginConfig;
|
|
64
|
+
"
|
|
65
|
+
`;
|
|
66
|
+
|
|
67
|
+
exports[`config utils > should snapshot config with tags 1`] = `
|
|
68
|
+
"import { AwsNxPluginConfig } from '@aws/nx-plugin';
|
|
69
|
+
|
|
70
|
+
export default { tags: ['tag1', 'tag2', 'tag3'] } satisfies AwsNxPluginConfig;
|
|
71
|
+
"
|
|
72
|
+
`;
|
|
73
|
+
|
|
74
|
+
exports[`config utils > should snapshot merged config with multiple keys 1`] = `
|
|
75
|
+
"import { AwsNxPluginConfig } from '@aws/nx-plugin';
|
|
76
|
+
|
|
77
|
+
export default {
|
|
78
|
+
iac: { provider: 'CDK' },
|
|
79
|
+
tags: ['tag1'],
|
|
80
|
+
} satisfies AwsNxPluginConfig;
|
|
81
|
+
"
|
|
82
|
+
`;
|
|
83
|
+
|
|
84
|
+
exports[`config utils > should snapshot simple iac config 1`] = `
|
|
85
|
+
"import { AwsNxPluginConfig } from '@aws/nx-plugin';
|
|
86
|
+
|
|
87
|
+
export default { iac: { provider: 'CDK' } } satisfies AwsNxPluginConfig;
|
|
88
|
+
"
|
|
89
|
+
`;
|
|
90
|
+
|
|
3
91
|
exports[`config utils > should update user config 1`] = `
|
|
4
92
|
"import { AwsNxPluginConfig } from '@aws/nx-plugin';
|
|
5
93
|
|
|
@@ -15,6 +15,7 @@ export declare const ensureAwsNxPluginConfig: (tree: Tree) => Promise<AwsNxPlugi
|
|
|
15
15
|
export declare const readAwsNxPluginConfig: (tree: Tree) => Promise<AwsNxPluginConfig | undefined>;
|
|
16
16
|
/**
|
|
17
17
|
* Update the aws nx plugin config file.
|
|
18
|
-
*
|
|
18
|
+
* Only the specified top-level keys are replaced; all other properties
|
|
19
|
+
* (including those containing JS expressions) are left untouched in source.
|
|
19
20
|
*/
|
|
20
21
|
export declare const updateAwsNxPluginConfig: (tree: Tree, configUpdate: Partial<AwsNxPluginConfig>) => Promise<void>;
|