@servicenow/sdk-build-core 3.0.2 → 4.0.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/dist/app.d.ts +25 -0
- package/dist/app.js +8 -0
- package/dist/app.js.map +1 -0
- package/dist/compiler.d.ts +60 -0
- package/dist/compiler.js +320 -0
- package/dist/compiler.js.map +1 -0
- package/dist/compression.d.ts +7 -0
- package/dist/compression.js +79 -0
- package/dist/compression.js.map +1 -0
- package/dist/crypto.d.ts +1 -0
- package/dist/crypto.js +9 -0
- package/dist/crypto.js.map +1 -0
- package/dist/diagnostic.d.ts +41 -0
- package/dist/diagnostic.js +130 -0
- package/dist/diagnostic.js.map +1 -0
- package/dist/{plugins/Diagnostic.d.ts → fluent-diagnostic.d.ts} +3 -2
- package/dist/fluent-diagnostic.js +23 -0
- package/dist/fluent-diagnostic.js.map +1 -0
- package/dist/fluent-directive.d.ts +8 -0
- package/dist/fluent-directive.js +54 -0
- package/dist/fluent-directive.js.map +1 -0
- package/dist/fluent-file.d.ts +5 -0
- package/dist/fluent-file.js +15 -0
- package/dist/fluent-file.js.map +1 -0
- package/dist/formatter.d.ts +11 -0
- package/dist/formatter.js +77 -0
- package/dist/formatter.js.map +1 -0
- package/dist/fs.d.ts +174 -0
- package/dist/fs.js +313 -0
- package/dist/fs.js.map +1 -0
- package/dist/guid.d.ts +2 -0
- package/dist/{GUID.js → guid.js} +3 -6
- package/dist/guid.js.map +1 -0
- package/dist/index.d.ts +19 -5
- package/dist/index.js +19 -5
- package/dist/index.js.map +1 -1
- package/dist/json.d.ts +5 -0
- package/dist/json.js +43 -0
- package/dist/json.js.map +1 -0
- package/dist/keys-registry.d.ts +64 -0
- package/dist/keys-registry.js +339 -0
- package/dist/keys-registry.js.map +1 -0
- package/dist/logger.d.ts +8 -0
- package/dist/logger.js +17 -0
- package/dist/logger.js.map +1 -0
- package/dist/now-config.d.ts +348 -0
- package/dist/now-config.js +283 -0
- package/dist/now-config.js.map +1 -0
- package/dist/path.d.ts +3 -0
- package/dist/path.js +12 -0
- package/dist/path.js.map +1 -0
- package/dist/plugins/cache.d.ts +20 -0
- package/dist/plugins/cache.js +46 -0
- package/dist/plugins/cache.js.map +1 -0
- package/dist/plugins/context.d.ts +85 -0
- package/dist/plugins/{Context.js → context.js} +1 -1
- package/dist/plugins/context.js.map +1 -0
- package/dist/plugins/database.d.ts +27 -0
- package/dist/plugins/database.js +102 -0
- package/dist/plugins/database.js.map +1 -0
- package/dist/plugins/file.d.ts +10 -0
- package/dist/plugins/{behaviors/Arranger.js → file.js} +1 -1
- package/dist/plugins/file.js.map +1 -0
- package/dist/plugins/index.d.ts +9 -5
- package/dist/plugins/index.js +9 -6
- package/dist/plugins/index.js.map +1 -1
- package/dist/plugins/plugin.d.ts +478 -0
- package/dist/plugins/plugin.js +533 -0
- package/dist/plugins/plugin.js.map +1 -0
- package/dist/plugins/product.d.ts +15 -0
- package/dist/plugins/product.js +38 -0
- package/dist/plugins/product.js.map +1 -0
- package/dist/plugins/project.d.ts +25 -0
- package/dist/plugins/{behaviors/Generator.js → project.js} +1 -1
- package/dist/plugins/project.js.map +1 -0
- package/dist/plugins/shape.d.ts +424 -0
- package/dist/plugins/shape.js +1181 -0
- package/dist/plugins/shape.js.map +1 -0
- package/dist/plugins/time.d.ts +12 -0
- package/dist/plugins/time.js +84 -0
- package/dist/plugins/time.js.map +1 -0
- package/dist/plugins/usage.d.ts +11 -0
- package/dist/plugins/usage.js +26 -0
- package/dist/plugins/usage.js.map +1 -0
- package/dist/prettier/config-loader.d.ts +13 -0
- package/dist/prettier/config-loader.js +105 -0
- package/dist/prettier/config-loader.js.map +1 -0
- package/dist/telemetry/index.d.ts +25 -0
- package/dist/telemetry/index.js +18 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/typescript.d.ts +293 -0
- package/dist/typescript.js +454 -0
- package/dist/typescript.js.map +1 -0
- package/dist/util/get-file-type.d.ts +2 -0
- package/dist/util/get-file-type.js +13 -0
- package/dist/util/get-file-type.js.map +1 -0
- package/dist/util/index.d.ts +2 -6
- package/dist/util/index.js +2 -6
- package/dist/util/index.js.map +1 -1
- package/dist/util/{Scope.js → is-sn-scope.js} +1 -1
- package/dist/util/is-sn-scope.js.map +1 -0
- package/dist/xml.d.ts +24 -0
- package/dist/xml.js +71 -0
- package/dist/xml.js.map +1 -0
- package/now.config.schema.json +336 -0
- package/package.json +22 -12
- package/src/app.ts +33 -0
- package/src/compiler.ts +384 -0
- package/src/compression.ts +93 -0
- package/src/crypto.ts +5 -0
- package/src/diagnostic.ts +108 -0
- package/src/{plugins/Diagnostic.ts → fluent-diagnostic.ts} +3 -10
- package/src/fluent-directive.ts +63 -0
- package/src/fluent-file.ts +13 -0
- package/src/formatter.ts +58 -0
- package/src/fs.ts +438 -0
- package/src/{GUID.ts → guid.ts} +2 -6
- package/src/index.ts +19 -5
- package/src/json.ts +20 -0
- package/src/keys-registry.ts +384 -0
- package/src/logger.ts +20 -0
- package/src/now-config.ts +337 -0
- package/src/path.ts +9 -0
- package/src/plugins/cache.ts +45 -0
- package/src/plugins/context.ts +93 -0
- package/src/plugins/database.ts +121 -0
- package/src/plugins/file.ts +19 -0
- package/src/plugins/index.ts +9 -5
- package/src/plugins/plugin.ts +995 -0
- package/src/plugins/product.ts +44 -0
- package/src/plugins/project.ts +39 -0
- package/src/plugins/shape.ts +1532 -0
- package/src/plugins/time.ts +108 -0
- package/src/plugins/usage.ts +26 -0
- package/src/prettier/config-loader.ts +130 -0
- package/src/telemetry/index.ts +27 -0
- package/src/typescript.ts +502 -0
- package/src/util/get-file-type.ts +11 -0
- package/src/util/index.ts +2 -6
- package/src/xml.ts +86 -0
- package/dist/GUID.d.ts +0 -2
- package/dist/GUID.js.map +0 -1
- package/dist/IncludePaths.d.ts +0 -25
- package/dist/IncludePaths.js +0 -97
- package/dist/IncludePaths.js.map +0 -1
- package/dist/Keys.d.ts +0 -32
- package/dist/Keys.js +0 -245
- package/dist/Keys.js.map +0 -1
- package/dist/TypeScript.d.ts +0 -5
- package/dist/TypeScript.js +0 -58
- package/dist/TypeScript.js.map +0 -1
- package/dist/XML.d.ts +0 -32
- package/dist/XML.js +0 -77
- package/dist/XML.js.map +0 -1
- package/dist/plugins/Context.d.ts +0 -190
- package/dist/plugins/Context.js.map +0 -1
- package/dist/plugins/Diagnostic.js +0 -28
- package/dist/plugins/Diagnostic.js.map +0 -1
- package/dist/plugins/Plugin.d.ts +0 -175
- package/dist/plugins/Plugin.js +0 -15
- package/dist/plugins/Plugin.js.map +0 -1
- package/dist/plugins/behaviors/Arranger.d.ts +0 -26
- package/dist/plugins/behaviors/Arranger.js.map +0 -1
- package/dist/plugins/behaviors/Composer.d.ts +0 -102
- package/dist/plugins/behaviors/Composer.js +0 -15
- package/dist/plugins/behaviors/Composer.js.map +0 -1
- package/dist/plugins/behaviors/Diagnostics.d.ts +0 -7
- package/dist/plugins/behaviors/Diagnostics.js +0 -3
- package/dist/plugins/behaviors/Diagnostics.js.map +0 -1
- package/dist/plugins/behaviors/Generator.d.ts +0 -21
- package/dist/plugins/behaviors/Generator.js.map +0 -1
- package/dist/plugins/behaviors/OwnedTables.d.ts +0 -6
- package/dist/plugins/behaviors/OwnedTables.js +0 -3
- package/dist/plugins/behaviors/OwnedTables.js.map +0 -1
- package/dist/plugins/behaviors/PostProcessor.d.ts +0 -5
- package/dist/plugins/behaviors/PostProcessor.js +0 -3
- package/dist/plugins/behaviors/PostProcessor.js.map +0 -1
- package/dist/plugins/behaviors/Serializer.d.ts +0 -30
- package/dist/plugins/behaviors/Serializer.js +0 -3
- package/dist/plugins/behaviors/Serializer.js.map +0 -1
- package/dist/plugins/behaviors/Transformer.d.ts +0 -23
- package/dist/plugins/behaviors/Transformer.js +0 -3
- package/dist/plugins/behaviors/Transformer.js.map +0 -1
- package/dist/plugins/behaviors/extractors/Data.d.ts +0 -119
- package/dist/plugins/behaviors/extractors/Data.js +0 -244
- package/dist/plugins/behaviors/extractors/Data.js.map +0 -1
- package/dist/plugins/behaviors/extractors/Extractors.d.ts +0 -63
- package/dist/plugins/behaviors/extractors/Extractors.js +0 -3
- package/dist/plugins/behaviors/extractors/Extractors.js.map +0 -1
- package/dist/plugins/behaviors/extractors/index.d.ts +0 -2
- package/dist/plugins/behaviors/extractors/index.js +0 -19
- package/dist/plugins/behaviors/extractors/index.js.map +0 -1
- package/dist/plugins/behaviors/index.d.ts +0 -9
- package/dist/plugins/behaviors/index.js +0 -26
- package/dist/plugins/behaviors/index.js.map +0 -1
- package/dist/plugins/util/CallExpression.d.ts +0 -5
- package/dist/plugins/util/CallExpression.js +0 -88
- package/dist/plugins/util/CallExpression.js.map +0 -1
- package/dist/plugins/util/CodeTransformation.d.ts +0 -95
- package/dist/plugins/util/CodeTransformation.js +0 -624
- package/dist/plugins/util/CodeTransformation.js.map +0 -1
- package/dist/plugins/util/ObjectLiteral.d.ts +0 -9
- package/dist/plugins/util/ObjectLiteral.js +0 -37
- package/dist/plugins/util/ObjectLiteral.js.map +0 -1
- package/dist/plugins/util/index.d.ts +0 -3
- package/dist/plugins/util/index.js +0 -20
- package/dist/plugins/util/index.js.map +0 -1
- package/dist/util/Debug.d.ts +0 -4
- package/dist/util/Debug.js +0 -20
- package/dist/util/Debug.js.map +0 -1
- package/dist/util/Directive.d.ts +0 -16
- package/dist/util/Directive.js +0 -107
- package/dist/util/Directive.js.map +0 -1
- package/dist/util/RuntimeTableSchema.d.ts +0 -5
- package/dist/util/RuntimeTableSchema.js +0 -58
- package/dist/util/RuntimeTableSchema.js.map +0 -1
- package/dist/util/Scope.js.map +0 -1
- package/dist/util/Util.d.ts +0 -1
- package/dist/util/Util.js +0 -12
- package/dist/util/Util.js.map +0 -1
- package/dist/util/XMLUploadParser.d.ts +0 -22
- package/dist/util/XMLUploadParser.js +0 -67
- package/dist/util/XMLUploadParser.js.map +0 -1
- package/src/IncludePaths.ts +0 -122
- package/src/Keys.ts +0 -274
- package/src/TypeScript.ts +0 -65
- package/src/XML.ts +0 -92
- package/src/plugins/Context.ts +0 -239
- package/src/plugins/Plugin.ts +0 -278
- package/src/plugins/behaviors/Arranger.ts +0 -42
- package/src/plugins/behaviors/Composer.ts +0 -125
- package/src/plugins/behaviors/Diagnostics.ts +0 -12
- package/src/plugins/behaviors/Generator.ts +0 -31
- package/src/plugins/behaviors/OwnedTables.ts +0 -5
- package/src/plugins/behaviors/PostProcessor.ts +0 -6
- package/src/plugins/behaviors/Serializer.ts +0 -40
- package/src/plugins/behaviors/Transformer.ts +0 -32
- package/src/plugins/behaviors/extractors/Data.ts +0 -332
- package/src/plugins/behaviors/extractors/Extractors.ts +0 -73
- package/src/plugins/behaviors/extractors/index.ts +0 -2
- package/src/plugins/behaviors/index.ts +0 -9
- package/src/plugins/util/CallExpression.ts +0 -110
- package/src/plugins/util/CodeTransformation.ts +0 -731
- package/src/plugins/util/ObjectLiteral.ts +0 -37
- package/src/plugins/util/index.ts +0 -3
- package/src/util/Debug.ts +0 -24
- package/src/util/Directive.ts +0 -123
- package/src/util/RuntimeTableSchema.ts +0 -44
- package/src/util/Util.ts +0 -7
- package/src/util/XMLUploadParser.ts +0 -90
- /package/dist/util/{Scope.d.ts → is-sn-scope.d.ts} +0 -0
- /package/src/util/{Scope.ts → is-sn-scope.ts} +0 -0
package/dist/fs.js
ADDED
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
var _a;
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.TsMorphFileSystemWrapper = exports.FileSystem = void 0;
|
|
31
|
+
const path_1 = require("./path");
|
|
32
|
+
const noop_1 = __importDefault(require("lodash/noop"));
|
|
33
|
+
const typescript_1 = require("./typescript");
|
|
34
|
+
const fg = __importStar(require("fast-glob"));
|
|
35
|
+
const readable_stream_1 = require("readable-stream");
|
|
36
|
+
var FileSystem;
|
|
37
|
+
(function (FileSystem) {
|
|
38
|
+
/**
|
|
39
|
+
* Synchronously copies the file or directory at the source path to the destination
|
|
40
|
+
* path. If the source path is a directory, only its contents will be copied, not the
|
|
41
|
+
* directory itself. If the source path is a file, the destination path cannot be a
|
|
42
|
+
* directory.
|
|
43
|
+
*
|
|
44
|
+
* If `options.filter` is provided, only entries for which the filter returns `true`
|
|
45
|
+
* will be copied.
|
|
46
|
+
*/
|
|
47
|
+
function copySync(fs, srcPath, destPath, options) {
|
|
48
|
+
if (fs.statSync(srcPath).isDirectory()) {
|
|
49
|
+
fs.readdirSync(srcPath, { withFileTypes: true })
|
|
50
|
+
.filter((file) => options?.filter(file.name) ?? true)
|
|
51
|
+
.forEach((file) => copySync(fs, path_1.path.join(srcPath, file.name), path_1.path.join(destPath, file.name), options));
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
if (!FileSystem.existsSync(fs, path_1.path.dirname(destPath))) {
|
|
55
|
+
fs.mkdirSync(path_1.path.dirname(destPath), { recursive: true });
|
|
56
|
+
}
|
|
57
|
+
fs.copyFileSync(srcPath, destPath);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
FileSystem.copySync = copySync;
|
|
61
|
+
/**
|
|
62
|
+
* Synchronously checks if the file or directory at the provided path exists.
|
|
63
|
+
*/
|
|
64
|
+
function existsSync(fs, path) {
|
|
65
|
+
try {
|
|
66
|
+
fs.accessSync(path);
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
FileSystem.existsSync = existsSync;
|
|
74
|
+
/*
|
|
75
|
+
* Ensures that a directory exists synchronously.
|
|
76
|
+
* If the directory does not exist, it will be created recursively.
|
|
77
|
+
*
|
|
78
|
+
* @param fs - The file system object.
|
|
79
|
+
* @param path - The path of the directory to ensure.
|
|
80
|
+
*/
|
|
81
|
+
function ensureDirSync(fs, path) {
|
|
82
|
+
if (!existsSync(fs, path)) {
|
|
83
|
+
fs.mkdirSync(path, { recursive: true });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
FileSystem.ensureDirSync = ensureDirSync;
|
|
87
|
+
/**
|
|
88
|
+
* Provides an implementation of a write stream for FileSystems that don't
|
|
89
|
+
* have one natively. Buffers all chunks in memory until finalized.
|
|
90
|
+
*/
|
|
91
|
+
function createWriteStream(fs, path) {
|
|
92
|
+
if ('createWriteStream' in fs && typeof fs.createWriteStream === 'function') {
|
|
93
|
+
return fs.createWriteStream(path);
|
|
94
|
+
}
|
|
95
|
+
const stream = new readable_stream_1.Writable();
|
|
96
|
+
// who needs streams when you have infinite memory?
|
|
97
|
+
const buffer = [];
|
|
98
|
+
stream._write = (chunk, _encoding, callback) => {
|
|
99
|
+
buffer.push(chunk);
|
|
100
|
+
callback();
|
|
101
|
+
};
|
|
102
|
+
stream._writev = (chunks, callback) => {
|
|
103
|
+
for (const { chunk, encoding } of chunks) {
|
|
104
|
+
stream._write(chunk, encoding, noop_1.default);
|
|
105
|
+
}
|
|
106
|
+
callback();
|
|
107
|
+
};
|
|
108
|
+
stream._final = (callback) => {
|
|
109
|
+
const totalSize = buffer.reduce((result, array) => result + array.length, 0);
|
|
110
|
+
const merged = new Uint8Array(totalSize);
|
|
111
|
+
let offset = 0;
|
|
112
|
+
buffer.forEach((array) => {
|
|
113
|
+
merged.set(array, offset);
|
|
114
|
+
offset += array.length;
|
|
115
|
+
});
|
|
116
|
+
fs.writeFileSync(path, Buffer.from(merged.buffer));
|
|
117
|
+
buffer.length = 0;
|
|
118
|
+
callback();
|
|
119
|
+
};
|
|
120
|
+
return stream;
|
|
121
|
+
}
|
|
122
|
+
FileSystem.createWriteStream = createWriteStream;
|
|
123
|
+
/**
|
|
124
|
+
* Provides an implementation of a read stream for FileSystems that don't
|
|
125
|
+
* have one natively. Reads the entire content as a single chunk.
|
|
126
|
+
*/
|
|
127
|
+
function createReadStream(fs, path) {
|
|
128
|
+
if ('createReadStream' in fs && typeof fs.createReadStream === 'function') {
|
|
129
|
+
return fs.createReadStream(path);
|
|
130
|
+
}
|
|
131
|
+
const stream = new readable_stream_1.Readable();
|
|
132
|
+
stream._read = () => {
|
|
133
|
+
stream.push(fs.readFileSync(path));
|
|
134
|
+
stream.push(null);
|
|
135
|
+
};
|
|
136
|
+
return stream;
|
|
137
|
+
}
|
|
138
|
+
FileSystem.createReadStream = createReadStream;
|
|
139
|
+
function traverseDirectory(fs, dir, options) {
|
|
140
|
+
if (!FileSystem.existsSync(fs, dir)) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const files = fs.readdirSync(dir, { withFileTypes: true });
|
|
144
|
+
const { extensions, ignore_extensions, visitor } = options || {};
|
|
145
|
+
for (const file of files) {
|
|
146
|
+
const filePath = path_1.path.resolve(dir, file.name);
|
|
147
|
+
if (file.isDirectory()) {
|
|
148
|
+
traverseDirectory(fs, filePath, options);
|
|
149
|
+
}
|
|
150
|
+
else if (ignore_extensions &&
|
|
151
|
+
ignore_extensions.find((e) => filePath.toLocaleLowerCase().endsWith(e.toLocaleLowerCase()))) {
|
|
152
|
+
//skip
|
|
153
|
+
}
|
|
154
|
+
else if (!extensions ||
|
|
155
|
+
extensions.length === 0 ||
|
|
156
|
+
extensions.some((e) => filePath.toLocaleLowerCase().endsWith(e.toLocaleLowerCase()))) {
|
|
157
|
+
visitor(filePath);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
FileSystem.traverseDirectory = traverseDirectory;
|
|
162
|
+
})(FileSystem || (exports.FileSystem = FileSystem = {}));
|
|
163
|
+
class TsMorphFileSystemWrapper {
|
|
164
|
+
fs;
|
|
165
|
+
static ENOENT = 'ENOENT';
|
|
166
|
+
constructor(fs) {
|
|
167
|
+
this.fs = fs;
|
|
168
|
+
}
|
|
169
|
+
deleteSync(path) {
|
|
170
|
+
try {
|
|
171
|
+
this.fs.rmSync(path, { recursive: true });
|
|
172
|
+
}
|
|
173
|
+
catch (err) {
|
|
174
|
+
// It is required to throw this specific subclass of error in order for ts-morph to work properly
|
|
175
|
+
throw this.#getFileNotFoundErrorIfNecessary(err, path);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
readFileSync(path, encoding = 'utf-8') {
|
|
179
|
+
try {
|
|
180
|
+
return this.fs.readFileSync(path, { encoding });
|
|
181
|
+
}
|
|
182
|
+
catch (err) {
|
|
183
|
+
// It is required to throw this specific subclass of error in order for ts-morph to work properly
|
|
184
|
+
throw this.#getFileNotFoundErrorIfNecessary(err, path);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
writeFileSync(path, text) {
|
|
188
|
+
this.fs.writeFileSync(path, text);
|
|
189
|
+
}
|
|
190
|
+
mkdirSync(path) {
|
|
191
|
+
this.fs.mkdirSync(path, { recursive: true });
|
|
192
|
+
}
|
|
193
|
+
moveSync(srcPath, destPath) {
|
|
194
|
+
this.fs.renameSync(srcPath, destPath);
|
|
195
|
+
}
|
|
196
|
+
copySync(srcPath, destPath) {
|
|
197
|
+
this.fs.copyFileSync(srcPath, destPath);
|
|
198
|
+
}
|
|
199
|
+
fileExistsSync(path) {
|
|
200
|
+
return FileSystem.existsSync(this.fs, path);
|
|
201
|
+
}
|
|
202
|
+
directoryExistsSync(path) {
|
|
203
|
+
return this.fileExistsSync(path);
|
|
204
|
+
}
|
|
205
|
+
readDirSync(dir) {
|
|
206
|
+
try {
|
|
207
|
+
const entries = this.fs.readdirSync(dir, { withFileTypes: true }).map((entry) => {
|
|
208
|
+
return {
|
|
209
|
+
name: entry.name,
|
|
210
|
+
isFile: entry.isFile(),
|
|
211
|
+
isDirectory: entry.isDirectory(),
|
|
212
|
+
isSymlink: entry.isSymbolicLink(),
|
|
213
|
+
};
|
|
214
|
+
});
|
|
215
|
+
for (const entry of entries) {
|
|
216
|
+
entry.name = path_1.path.join(dir, entry.name);
|
|
217
|
+
if (entry.isSymlink) {
|
|
218
|
+
try {
|
|
219
|
+
const info = this.fs.statSync(entry.name);
|
|
220
|
+
if (info != null) {
|
|
221
|
+
entry.isDirectory = info.isDirectory();
|
|
222
|
+
entry.isFile = info.isFile();
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
catch {
|
|
226
|
+
// Ignore
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return entries;
|
|
231
|
+
}
|
|
232
|
+
catch (err) {
|
|
233
|
+
// It is required to throw this specific subclass of error in order for ts-morph to work properly
|
|
234
|
+
throw this.#getDirectoryNotFoundErrorIfNecessary(err, dir);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
globSync(patterns, opts) {
|
|
238
|
+
return fg.sync(patterns.map((pattern) => (this.fileExistsSync(pattern) ? fg.convertPathToPattern(pattern) : pattern)), {
|
|
239
|
+
absolute: true,
|
|
240
|
+
cwd: this.getCurrentDirectory(),
|
|
241
|
+
...opts,
|
|
242
|
+
fs: {
|
|
243
|
+
readdir: this.fs.readdirSync.bind(this.fs),
|
|
244
|
+
readdirSync: this.fs.readdirSync.bind(this.fs),
|
|
245
|
+
stat: this.fs.statSync.bind(this.fs),
|
|
246
|
+
statSync: this.fs.statSync.bind(this.fs),
|
|
247
|
+
lstat: this.fs.lstatSync.bind(this.fs),
|
|
248
|
+
lstatSync: this.fs.lstatSync.bind(this.fs),
|
|
249
|
+
}, // TODO: There are probably some compatibility issues here that will cause subtle bugs
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
realpathSync(path) {
|
|
253
|
+
return this.fs.realpathSync(path);
|
|
254
|
+
}
|
|
255
|
+
getCurrentDirectory() {
|
|
256
|
+
return path_1.path.resolve();
|
|
257
|
+
}
|
|
258
|
+
isCaseSensitive() {
|
|
259
|
+
return false; // TODO: Should we try to do something more sophisticated here?
|
|
260
|
+
}
|
|
261
|
+
async delete(path) {
|
|
262
|
+
this.deleteSync(path);
|
|
263
|
+
}
|
|
264
|
+
async readFile(path, encoding) {
|
|
265
|
+
return this.readFileSync(path, encoding);
|
|
266
|
+
}
|
|
267
|
+
async writeFile(path, text) {
|
|
268
|
+
this.writeFileSync(path, text);
|
|
269
|
+
}
|
|
270
|
+
async mkdir(path) {
|
|
271
|
+
this.mkdirSync(path);
|
|
272
|
+
}
|
|
273
|
+
async move(srcPath, destPath) {
|
|
274
|
+
this.moveSync(srcPath, destPath);
|
|
275
|
+
}
|
|
276
|
+
async copy(srcPath, destPath) {
|
|
277
|
+
this.copySync(srcPath, destPath);
|
|
278
|
+
}
|
|
279
|
+
async fileExists(path) {
|
|
280
|
+
return this.fileExistsSync(path);
|
|
281
|
+
}
|
|
282
|
+
async directoryExists(path) {
|
|
283
|
+
return this.directoryExistsSync(path);
|
|
284
|
+
}
|
|
285
|
+
async glob(patterns) {
|
|
286
|
+
return this.globSync(patterns);
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Returns a specific subclass of error when a directory is not found which is
|
|
290
|
+
* required for ts-morph to work properly.
|
|
291
|
+
*/
|
|
292
|
+
#getDirectoryNotFoundErrorIfNecessary(err, path) {
|
|
293
|
+
return this.#isNotExistsError(err) ? new typescript_1.ts.DirectoryNotFoundError(path) : err;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Returns a specific subclass of error when a file is not found which is required
|
|
297
|
+
* for ts-morph to work properly.
|
|
298
|
+
*/
|
|
299
|
+
#getFileNotFoundErrorIfNecessary(err, path) {
|
|
300
|
+
return this.#isNotExistsError(err) ? new typescript_1.ts.FileNotFoundError(path) : err;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Checks if the error is a "not exists" error. This is copied directly from one
|
|
304
|
+
* of ts-morph's internal `FileSystemHost` implementations.
|
|
305
|
+
*/
|
|
306
|
+
#isNotExistsError(err) {
|
|
307
|
+
return ((err != null && err.code === _a.ENOENT) ||
|
|
308
|
+
(err != null && err?.constructor?.name === 'NotFound'));
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
exports.TsMorphFileSystemWrapper = TsMorphFileSystemWrapper;
|
|
312
|
+
_a = TsMorphFileSystemWrapper;
|
|
313
|
+
//# sourceMappingURL=fs.js.map
|
package/dist/fs.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../src/fs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAA6B;AAC7B,uDAA8B;AAC9B,6CAAiC;AACjC,8CAA+B;AAC/B,qDAAoD;AAqFpD,IAAiB,UAAU,CA6K1B;AA7KD,WAAiB,UAAU;IAwBvB;;;;;;;;OAQG;IACH,SAAgB,QAAQ,CACpB,EA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IAAI,IAAI,IAAI,GAAG,CAAC,IAAI,KAAK,EAAwB,CAAC,MAAM,CAAC;YAC7D,CAAC,GAAG,IAAI,IAAI,IAAI,GAAG,EAAE,WAAW,EAAE,IAAI,KAAK,UAAU,CAAC,CACzD,CAAA;IACL,CAAC;;AA5KL,4DA6KC"}
|
package/dist/guid.d.ts
ADDED
package/dist/{GUID.js → guid.js}
RENAMED
|
@@ -2,16 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GUID = GUID;
|
|
4
4
|
exports.isGUID = isGUID;
|
|
5
|
-
const
|
|
5
|
+
const crypto_1 = require("./crypto");
|
|
6
6
|
function GUID() {
|
|
7
|
-
return
|
|
7
|
+
return crypto_1.crypto.randomUUID().replaceAll('-', '');
|
|
8
8
|
}
|
|
9
9
|
// Matches a hex string exactly 32 characters long
|
|
10
10
|
const snIDRegex = /^[a-f0-9]{32}$/i;
|
|
11
11
|
function isGUID(guid) {
|
|
12
|
-
if (typeof guid !== 'string') {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
12
|
return snIDRegex.test(guid);
|
|
16
13
|
}
|
|
17
|
-
//# sourceMappingURL=
|
|
14
|
+
//# sourceMappingURL=guid.js.map
|
package/dist/guid.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guid.js","sourceRoot":"","sources":["../src/guid.ts"],"names":[],"mappings":";;AAEA,oBAEC;AAKD,wBAEC;AAXD,qCAAiC;AAEjC,SAAgB,IAAI;IAChB,OAAO,eAAM,CAAC,UAAU,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;AAClD,CAAC;AAED,kDAAkD;AAClD,MAAM,SAAS,GAAG,iBAAiB,CAAA;AAEnC,SAAgB,MAAM,CAAC,IAAY;IAC/B,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC/B,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
export * from './util';
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './XML';
|
|
2
|
+
export * from './xml';
|
|
4
3
|
export * from './plugins';
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
7
|
-
export * from './
|
|
4
|
+
export * from './guid';
|
|
5
|
+
export * from './keys-registry';
|
|
6
|
+
export * from './fluent-diagnostic';
|
|
7
|
+
export * from './fluent-directive';
|
|
8
|
+
export * from './fluent-file';
|
|
9
|
+
export * from './now-config';
|
|
10
|
+
export * from './compiler';
|
|
11
|
+
export * from './diagnostic';
|
|
12
|
+
export * from './app';
|
|
13
|
+
export * from './json';
|
|
14
|
+
export * from './logger';
|
|
15
|
+
export * from './fs';
|
|
16
|
+
export * from './path';
|
|
17
|
+
export * from './typescript';
|
|
18
|
+
export * from './crypto';
|
|
19
|
+
export * from './compression';
|
|
20
|
+
export * from './formatter';
|
|
21
|
+
export * from './telemetry';
|
package/dist/index.js
CHANGED
|
@@ -15,10 +15,24 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./util"), exports);
|
|
18
|
-
__exportStar(require("./
|
|
19
|
-
__exportStar(require("./XML"), exports);
|
|
18
|
+
__exportStar(require("./xml"), exports);
|
|
20
19
|
__exportStar(require("./plugins"), exports);
|
|
21
|
-
__exportStar(require("./
|
|
22
|
-
__exportStar(require("./
|
|
23
|
-
__exportStar(require("./
|
|
20
|
+
__exportStar(require("./guid"), exports);
|
|
21
|
+
__exportStar(require("./keys-registry"), exports);
|
|
22
|
+
__exportStar(require("./fluent-diagnostic"), exports);
|
|
23
|
+
__exportStar(require("./fluent-directive"), exports);
|
|
24
|
+
__exportStar(require("./fluent-file"), exports);
|
|
25
|
+
__exportStar(require("./now-config"), exports);
|
|
26
|
+
__exportStar(require("./compiler"), exports);
|
|
27
|
+
__exportStar(require("./diagnostic"), exports);
|
|
28
|
+
__exportStar(require("./app"), exports);
|
|
29
|
+
__exportStar(require("./json"), exports);
|
|
30
|
+
__exportStar(require("./logger"), exports);
|
|
31
|
+
__exportStar(require("./fs"), exports);
|
|
32
|
+
__exportStar(require("./path"), exports);
|
|
33
|
+
__exportStar(require("./typescript"), exports);
|
|
34
|
+
__exportStar(require("./crypto"), exports);
|
|
35
|
+
__exportStar(require("./compression"), exports);
|
|
36
|
+
__exportStar(require("./formatter"), exports);
|
|
37
|
+
__exportStar(require("./telemetry"), exports);
|
|
24
38
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAsB;AACtB
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAsB;AACtB,wCAAqB;AACrB,4CAAyB;AACzB,yCAAsB;AACtB,kDAA+B;AAC/B,sDAAmC;AACnC,qDAAkC;AAClC,gDAA6B;AAC7B,+CAA4B;AAC5B,6CAA0B;AAC1B,+CAA4B;AAC5B,wCAAqB;AACrB,yCAAsB;AACtB,2CAAwB;AACxB,uCAAoB;AACpB,yCAAsB;AACtB,+CAA4B;AAC5B,2CAAwB;AACxB,gDAA6B;AAC7B,8CAA2B;AAC3B,8CAA2B"}
|
package/dist/json.d.ts
ADDED
package/dist/json.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.JSON5 = void 0;
|
|
27
|
+
exports.readJson = readJson;
|
|
28
|
+
const path_1 = require("./path");
|
|
29
|
+
const compiler_1 = require("./compiler");
|
|
30
|
+
const JSON5 = __importStar(require("json5"));
|
|
31
|
+
exports.JSON5 = JSON5;
|
|
32
|
+
function readJson(path, filename, fsOrCompiler) {
|
|
33
|
+
const filePath = path_1.path.resolve(path, filename);
|
|
34
|
+
try {
|
|
35
|
+
return JSON5.parse(fsOrCompiler instanceof compiler_1.Compiler
|
|
36
|
+
? fsOrCompiler.getSourceFileOrThrow(filePath).getFullText()
|
|
37
|
+
: fsOrCompiler.readFileSync(filePath, { encoding: 'utf-8' }));
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
throw new Error(`Failed to parse JSON file: ${filePath} (Reason: ${e instanceof Error ? e.message : e})`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=json.js.map
|
package/dist/json.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,4BAYC;AAnBD,iCAA2C;AAE3C,yCAAqC;AAErC,6CAA8B;AACrB,sBAAK;AAEd,SAAgB,QAAQ,CAAC,IAAY,EAAE,QAAgB,EAAE,YAAmC;IACxF,MAAM,QAAQ,GAAG,WAAU,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;IAEnD,IAAI,CAAC;QACD,OAAO,KAAK,CAAC,KAAK,CACd,YAAY,YAAY,mBAAQ;YAC5B,CAAC,CAAC,YAAY,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE;YAC3D,CAAC,CAAC,YAAY,CAAC,YAAY,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CACnE,CAAA;IACL,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CAAC,8BAA8B,QAAQ,aAAa,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;IAC7G,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ts } from './typescript';
|
|
2
|
+
import type { App } from './app';
|
|
3
|
+
import type { Compiler } from './compiler';
|
|
4
|
+
import type { CoalesceKeys } from './plugins';
|
|
5
|
+
import { Formatter } from './formatter';
|
|
6
|
+
import type { FileSystem } from './fs';
|
|
7
|
+
export declare const KEYS_MODULE = "@servicenow/sdk/global";
|
|
8
|
+
export declare const KEYS_FILE_NAME = "keys.ts";
|
|
9
|
+
export declare class KeysRegistry {
|
|
10
|
+
private readonly formatter;
|
|
11
|
+
private readonly file;
|
|
12
|
+
private readonly usedIds;
|
|
13
|
+
private registry;
|
|
14
|
+
constructor(compiler: Compiler, project: App, fs: FileSystem);
|
|
15
|
+
static parseKeysFile(keysFile: ts.SourceFile): Now.Internal.KeysRegistry;
|
|
16
|
+
private static getKeysInterface;
|
|
17
|
+
private use;
|
|
18
|
+
getSourceFile(): ts.SourceFile;
|
|
19
|
+
private queryExplicitKey;
|
|
20
|
+
queryExplicitId(table: string, key: string | number): string | undefined;
|
|
21
|
+
private registerExplicitKey;
|
|
22
|
+
registerExplicitId(table: string, key: string | number, guidOverride?: string): string;
|
|
23
|
+
private deleteExplicitKey;
|
|
24
|
+
deleteExplicitId(table: string, key: string | number, guidOverride?: string): string;
|
|
25
|
+
private queryCompositeKey;
|
|
26
|
+
queryCompositeId(table: string, query: CoalesceKeys): string | undefined;
|
|
27
|
+
private registerCompositeKey;
|
|
28
|
+
registerCompositeId(table: string, key: CoalesceKeys, guidOverride?: string): string;
|
|
29
|
+
private deleteCompositeKey;
|
|
30
|
+
deleteCompositeId(table: string, key: CoalesceKeys, guidOverride?: string): string;
|
|
31
|
+
private serializeCoalesceKeys;
|
|
32
|
+
/**
|
|
33
|
+
* Checks if the coalesce keys from `left` are equal to those specified in `right`. If there
|
|
34
|
+
* are keys in `left` that aren't present in `right`, they are ignored. However, if there are
|
|
35
|
+
* keys in `right` that aren't present in `left`, the two are considered NOT equal.
|
|
36
|
+
*
|
|
37
|
+
* If any nested coalesce keys are present on either side, they are considered equal when any
|
|
38
|
+
* ONE of the following conditions are met:
|
|
39
|
+
*
|
|
40
|
+
* A) One of the values is a string that matches the nested key's ID
|
|
41
|
+
*
|
|
42
|
+
* { id: '123', key: { k: 'v' } } == '123' }
|
|
43
|
+
*
|
|
44
|
+
* B) Both values are nested keys with matching IDs
|
|
45
|
+
*
|
|
46
|
+
* { id: '123', key: { k: 'v' } } == { id: '123', key: { ... } }
|
|
47
|
+
*
|
|
48
|
+
* C) Both values are nested keys with matching coalesce values
|
|
49
|
+
*
|
|
50
|
+
* { id: '123', key: { k: 'v' } } == { id: '456', key: { k: 'v' } }
|
|
51
|
+
*
|
|
52
|
+
* For condition C, the nested keys are compared recursively, so if they contain any of their
|
|
53
|
+
* own nested keys, they will be compared in the same way.
|
|
54
|
+
*/
|
|
55
|
+
private coalesceKeysAreEqual;
|
|
56
|
+
mapLegacyKeys(obj: NonNullable<object>, table?: string): object;
|
|
57
|
+
getEffectiveExplicitKeys(): Now.Internal.KeysRegistry['explicit'];
|
|
58
|
+
getEffectiveCompositeKeys(): Now.Internal.KeysRegistry['composite'];
|
|
59
|
+
getEffectiveDeletedKeys(): Now.Internal.AnyKey[];
|
|
60
|
+
commit(formatter?: Formatter): Promise<void>;
|
|
61
|
+
private static getCode;
|
|
62
|
+
reload(): void;
|
|
63
|
+
getValue(): Now.Internal.KeysRegistry;
|
|
64
|
+
}
|