@trackunit/nx-utils 0.0.8 → 0.0.10

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/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [0.0.10](https://github.com/Trackunit/manager/compare/nx-utils/0.0.9...nx-utils/0.0.10) (2023-04-19)
6
+
7
+ ## [0.0.9](https://github.com/Trackunit/manager/compare/nx-utils/0.0.8...nx-utils/0.0.9) (2023-04-19)
8
+
5
9
  ## [0.0.8](https://github.com/Trackunit/manager/compare/nx-utils/0.0.7...nx-utils/0.0.8) (2023-04-14)
6
10
 
7
11
  ## [0.0.7](https://github.com/Trackunit/manager/compare/nx-utils/0.0.6...nx-utils/0.0.7) (2023-04-14)
package/package.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "name": "@trackunit/nx-utils",
3
- "version": "0.0.8",
4
- "main": "src/lib/index.ts",
3
+ "version": "0.0.10",
4
+ "main": "src/index.js",
5
5
  "repository": "https://github.com/Trackunit/manager",
6
6
  "license": "SEE LICENSE IN LICENSE.txt",
7
7
  "dependencies": {
8
- "@phenomnomnominal/tsquery": "4.2.0",
9
8
  "tslib": "2.4.1"
10
9
  },
11
10
  "types": "./src/index.d.ts"
package/src/index.js CHANGED
@@ -9,7 +9,6 @@ Object.defineProperty(exports, "readFile", { enumerable: true, get: function ()
9
9
  Object.defineProperty(exports, "readJson", { enumerable: true, get: function () { return testing_1.readJson; } });
10
10
  Object.defineProperty(exports, "uniq", { enumerable: true, get: function () { return testing_1.uniq; } });
11
11
  Object.defineProperty(exports, "updateFile", { enumerable: true, get: function () { return testing_1.updateFile; } });
12
- tslib_1.__exportStar(require("./ast/astUtils"), exports);
13
12
  tslib_1.__exportStar(require("./nxTestUtils"), exports);
14
13
  tslib_1.__exportStar(require("./projectUtils"), exports);
15
14
  //# sourceMappingURL=index.js.map
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/nx/utils/src/index.ts"],"names":[],"mappings":";;;;AAAA,iDAAiD;AACjD,mDAAgG;AAAvF,0GAAA,eAAe,OAAA;AAAE,mGAAA,QAAQ,OAAA;AAAE,mGAAA,QAAQ,OAAA;AAAE,+FAAA,IAAI,OAAA;AAAE,qGAAA,UAAU,OAAA;AAC9D,yDAA+B;AAC/B,wDAA8B;AAC9B,yDAA+B","sourcesContent":["// eslint-disable-next-line no-restricted-imports\nexport { checkFilesExist, readFile, readJson, uniq, updateFile } from \"@nrwl/nx-plugin/testing\";\nexport * from \"./ast/astUtils\";\nexport * from \"./nxTestUtils\";\nexport * from \"./projectUtils\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/nx/utils/src/index.ts"],"names":[],"mappings":";;;;AAAA,iDAAiD;AACjD,mDAAgG;AAAvF,0GAAA,eAAe,OAAA;AAAE,mGAAA,QAAQ,OAAA;AAAE,mGAAA,QAAQ,OAAA;AAAE,+FAAA,IAAI,OAAA;AAAE,qGAAA,UAAU,OAAA;AAC9D,wDAA8B;AAC9B,yDAA+B","sourcesContent":["// eslint-disable-next-line no-restricted-imports\nexport { checkFilesExist, readFile, readJson, uniq, updateFile } from \"@nrwl/nx-plugin/testing\";\nexport * from \"./nxTestUtils\";\nexport * from \"./projectUtils\";\n"]}
@@ -1,65 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addPropertyWithName = exports.removePropertyWithName = void 0;
4
- const tslib_1 = require("tslib");
5
- const tsquery_1 = require("@phenomnomnominal/tsquery");
6
- const ts = tslib_1.__importStar(require("typescript"));
7
- /**
8
- * This function removes a property with a given name from an object literal
9
- * provided as a text string.
10
- *
11
- * @param {string} fileContent - the source code as text
12
- * @param {string} propertyName - the property to remove from the source code
13
- */
14
- function removePropertyWithName(fileContent, propertyName) {
15
- const sourceFile = tsquery_1.tsquery.ast(fileContent);
16
- const updatedSourceFile = tsquery_1.tsquery.map(sourceFile, "ObjectLiteralExpression", node => {
17
- if (ts.isObjectLiteralExpression(node)) {
18
- // Filter out the given property
19
- const updatedProperties = node.properties.filter(property => {
20
- return !(ts.isPropertyAssignment(property) &&
21
- ts.isIdentifier(property.name) &&
22
- property.name.text === propertyName);
23
- });
24
- return ts.factory.createObjectLiteralExpression(updatedProperties, true);
25
- }
26
- return node;
27
- });
28
- return ts.createPrinter().printFile(updatedSourceFile);
29
- }
30
- exports.removePropertyWithName = removePropertyWithName;
31
- /**
32
- * This function adds a new property with a given name and value to an object literal
33
- * provided as a text string.
34
- *
35
- * @param {string} fileContent - the source code as text
36
- * @param {string} propertyName - the name of the property to add
37
- * @param {string | string[]} propertyValue - the value of the property to add
38
- */
39
- function addPropertyWithName(fileContent, propertyName, propertyValue) {
40
- const sourceFile = tsquery_1.tsquery.ast(fileContent);
41
- const updatedSourceFile = tsquery_1.tsquery.map(sourceFile, "ObjectLiteralExpression", node => {
42
- if (ts.isObjectLiteralExpression(node)) {
43
- // Add a new property to the object literal
44
- let updatedProperties;
45
- if (typeof propertyValue === "string") {
46
- updatedProperties = [
47
- ...node.properties,
48
- ts.factory.createPropertyAssignment(ts.factory.createIdentifier(propertyName), ts.factory.createStringLiteral(propertyValue)),
49
- ];
50
- }
51
- else if (Array.isArray(propertyValue)) {
52
- const arrayLiteral = ts.factory.createArrayLiteralExpression(propertyValue.map(value => ts.factory.createStringLiteral(value)));
53
- updatedProperties = [
54
- ...node.properties,
55
- ts.factory.createPropertyAssignment(ts.factory.createIdentifier(propertyName), arrayLiteral),
56
- ];
57
- }
58
- return ts.factory.createObjectLiteralExpression(updatedProperties, true);
59
- }
60
- return node;
61
- });
62
- return ts.createPrinter().printFile(updatedSourceFile);
63
- }
64
- exports.addPropertyWithName = addPropertyWithName;
65
- //# sourceMappingURL=astUtils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"astU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;YACtC,2CAA2C;YAC3C,IAAI,iBAAiB,CAAC;YACtB,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE;gBACrC,iBAAiB,GAAG;oBAClB,GAAG,IAAI,CAAC,UAAU;oBAClB,EAAE,CAAC,OAAO,CAAC,wBAAwB,CACjC,EAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,YAAY,CAAC,EACzC,EAAE,CAAC,OAAO,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAC9C;iBACF,CAAC;aACH;iBAAM,IAAI,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;gBACvC,MAAM,YAAY,GAAG,EAAE,CAAC,OAAO,CAAC,4BAA4B,CAC1D,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAClE,CAAC;gBACF,iBAAiB,GAAG;oBAClB,GAAG,IAAI,CAAC,UAAU;oBAClB,EAAE,CAAC,OAAO,CAAC,wBAAwB,CAAC,EAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC;iBAC7F,CAAC;aACH;YACD,OAAO,EAAE,CAAC,OAAO,CAAC,6BAA6B,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;SAC1E;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,CAAC,aAAa,EAAE,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;AACzD,CAAC;AA5BD,kDA4BC","sourcesContent":["import { tsquery } from \"@phenomnomnominal/tsquery\";\nimport * as ts from \"typescript\";\n\n/**\n * This function removes a property with a given name from an object literal\n * provided as a text string.\n *\n * @param {string} fileContent - the source code as text\n * @param {string} propertyName - the property to remove from the source code\n */\nexport function removePropertyWithName(fileContent: string, propertyName: string) {\n const sourceFile = tsquery.ast(fileContent);\n const updatedSourceFile = tsquery.map(sourceFile, \"ObjectLiteralExpression\", node => {\n if (ts.isObjectLiteralExpression(node)) {\n // Filter out the given property\n const updatedProperties = node.properties.filter(property => {\n return !(\n ts.isPropertyAssignment(property) &&\n ts.isIdentifier(property.name) &&\n property.name.text === propertyName\n );\n });\n return ts.factory.createObjectLiteralExpression(updatedProperties, true);\n }\n return node;\n });\n return ts.createPrinter().printFile(updatedSourceFile);\n}\n\n/**\n * This function adds a new property with a given name and value to an object literal\n * provided as a text string.\n *\n * @param {string} fileContent - the source code as text\n * @param {string} propertyName - the name of the property to add\n * @param {string | string[]} propertyValue - the value of the property to add\n */\nexport function addPropertyWithName(fileContent: string, propertyName: string, propertyValue: string | string[]) {\n const sourceFile = tsquery.ast(fileContent);\n const updatedSourceFile = tsquery.map(sourceFile, \"ObjectLiteralExpression\", node => {\n if (ts.isObjectLiteralExpression(node)) {\n // Add a new property to the object literal\n let updatedProperties;\n if (typeof propertyValue === \"string\") {\n updatedProperties = [\n ...node.properties,\n ts.factory.createPropertyAssignment(\n ts.factory.createIdentifier(propertyName),\n ts.factory.createStringLiteral(propertyValue)\n ),\n ];\n } else if (Array.isArray(propertyValue)) {\n const arrayLiteral = ts.factory.createArrayLiteralExpression(\n propertyValue.map(value => ts.factory.createStringLiteral(value))\n );\n updatedProperties = [\n ...node.properties,\n ts.factory.createPropertyAssignment(ts.factory.createIdentifier(propertyName), arrayLiteral),\n ];\n }\n return ts.factory.createObjectLiteralExpression(updatedProperties, true);\n }\n return node;\n });\n return ts.createPrinter().printFile(updatedSourceFile);\n}\n"]}