@servicenow/sdk-build-core 3.0.3 → 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 -83
- 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 -98
- 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
|
@@ -0,0 +1,130 @@
|
|
|
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.Diagnostic = void 0;
|
|
27
|
+
const lsp = __importStar(require("vscode-languageserver"));
|
|
28
|
+
const os = __importStar(require("os"));
|
|
29
|
+
const typescript_1 = require("./typescript");
|
|
30
|
+
class Diagnostic {
|
|
31
|
+
message;
|
|
32
|
+
file;
|
|
33
|
+
position;
|
|
34
|
+
code;
|
|
35
|
+
source;
|
|
36
|
+
level;
|
|
37
|
+
constructor(message, file, position, code, source, level = Diagnostic.Level.Error) {
|
|
38
|
+
this.message = message;
|
|
39
|
+
this.file = file;
|
|
40
|
+
this.position = position;
|
|
41
|
+
this.code = code;
|
|
42
|
+
this.source = source;
|
|
43
|
+
this.level = level;
|
|
44
|
+
}
|
|
45
|
+
asLspDiagnostic() {
|
|
46
|
+
const start = this.file.compilerNode.getLineAndCharacterOfPosition(this.position.start);
|
|
47
|
+
const end = this.file.compilerNode.getLineAndCharacterOfPosition(this.position.end);
|
|
48
|
+
return {
|
|
49
|
+
message: this.message,
|
|
50
|
+
range: { start, end },
|
|
51
|
+
severity: Diagnostic.Level.toSeverity(this.level),
|
|
52
|
+
code: this.code,
|
|
53
|
+
source: this.source,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
getFormattedText(colors = true) {
|
|
57
|
+
const host = {
|
|
58
|
+
getCurrentDirectory: () => this.file.getProject().getFileSystem().getCurrentDirectory(),
|
|
59
|
+
getCanonicalFileName: (fileName) => fileName,
|
|
60
|
+
getNewLine: () => os.EOL,
|
|
61
|
+
};
|
|
62
|
+
return colors
|
|
63
|
+
? typescript_1.ts.ts.formatDiagnosticsWithColorAndContext([this.asTypeScriptDiagnostic()], host)
|
|
64
|
+
: typescript_1.ts.ts.formatDiagnostic(this.asTypeScriptDiagnostic(), host);
|
|
65
|
+
}
|
|
66
|
+
print(logger, { noThrow = false, colors = true } = {}) {
|
|
67
|
+
if (this.level === Diagnostic.Level.Error) {
|
|
68
|
+
const errorMessage = this.getFormattedText(colors);
|
|
69
|
+
if (noThrow) {
|
|
70
|
+
logger.error(errorMessage);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
logger.error('Diagnostic errors found in source files, fix errors and re-run transform/build');
|
|
74
|
+
throw new Error(errorMessage);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else if (this.level === Diagnostic.Level.Warn) {
|
|
78
|
+
logger.warn(this.getFormattedText(colors));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.Diagnostic = Diagnostic;
|
|
83
|
+
(function (Diagnostic) {
|
|
84
|
+
let Level;
|
|
85
|
+
(function (Level) {
|
|
86
|
+
Level[Level["Error"] = 1] = "Error";
|
|
87
|
+
Level[Level["Warn"] = 2] = "Warn";
|
|
88
|
+
Level[Level["Info"] = 3] = "Info";
|
|
89
|
+
Level[Level["Hint"] = 4] = "Hint";
|
|
90
|
+
})(Level = Diagnostic.Level || (Diagnostic.Level = {}));
|
|
91
|
+
(function (Level) {
|
|
92
|
+
function fromCategory(category) {
|
|
93
|
+
return {
|
|
94
|
+
[typescript_1.ts.DiagnosticCategory.Error]: Diagnostic.Level.Error,
|
|
95
|
+
[typescript_1.ts.DiagnosticCategory.Warning]: Diagnostic.Level.Warn,
|
|
96
|
+
[typescript_1.ts.DiagnosticCategory.Message]: Diagnostic.Level.Info,
|
|
97
|
+
[typescript_1.ts.DiagnosticCategory.Suggestion]: Diagnostic.Level.Hint,
|
|
98
|
+
}[category];
|
|
99
|
+
}
|
|
100
|
+
Level.fromCategory = fromCategory;
|
|
101
|
+
function toCategory(level) {
|
|
102
|
+
return {
|
|
103
|
+
[Diagnostic.Level.Error]: typescript_1.ts.DiagnosticCategory.Error,
|
|
104
|
+
[Diagnostic.Level.Warn]: typescript_1.ts.DiagnosticCategory.Warning,
|
|
105
|
+
[Diagnostic.Level.Info]: typescript_1.ts.DiagnosticCategory.Message,
|
|
106
|
+
[Diagnostic.Level.Hint]: typescript_1.ts.DiagnosticCategory.Suggestion,
|
|
107
|
+
}[level];
|
|
108
|
+
}
|
|
109
|
+
Level.toCategory = toCategory;
|
|
110
|
+
function fromSeverity(severity) {
|
|
111
|
+
return {
|
|
112
|
+
[lsp.DiagnosticSeverity.Error]: Diagnostic.Level.Error,
|
|
113
|
+
[lsp.DiagnosticSeverity.Warning]: Diagnostic.Level.Warn,
|
|
114
|
+
[lsp.DiagnosticSeverity.Information]: Diagnostic.Level.Info,
|
|
115
|
+
[lsp.DiagnosticSeverity.Hint]: Diagnostic.Level.Hint,
|
|
116
|
+
}[severity];
|
|
117
|
+
}
|
|
118
|
+
Level.fromSeverity = fromSeverity;
|
|
119
|
+
function toSeverity(level) {
|
|
120
|
+
return {
|
|
121
|
+
[Diagnostic.Level.Error]: lsp.DiagnosticSeverity.Error,
|
|
122
|
+
[Diagnostic.Level.Warn]: lsp.DiagnosticSeverity.Warning,
|
|
123
|
+
[Diagnostic.Level.Info]: lsp.DiagnosticSeverity.Information,
|
|
124
|
+
[Diagnostic.Level.Hint]: lsp.DiagnosticSeverity.Hint,
|
|
125
|
+
}[level];
|
|
126
|
+
}
|
|
127
|
+
Level.toSeverity = toSeverity;
|
|
128
|
+
})(Level = Diagnostic.Level || (Diagnostic.Level = {}));
|
|
129
|
+
})(Diagnostic || (exports.Diagnostic = Diagnostic = {}));
|
|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kB,CAAC,WAAW,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,IAAI;gBAC3D,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,IAAI;aACvD,CAAC,QAAQ,CAAC,CAAA;QACf,CAAC;QAPe,kBAAY,eAO3B,CAAA;QAED,SAAgB,UAAU,CAAC,KAAY;YACnC,OAAO;gBACH,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,kBAAkB,CAAC,KAAK;gBACtD,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,kBAAkB,CAAC,OAAO;gBACvD,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,kBAAkB,CAAC,WAAW;gBAC3D,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,kBAAkB,CAAC,IAAI;aACvD,CAAC,KAAK,CAAC,CAAA;QACZ,CAAC;QAPe,gBAAU,aAOzB,CAAA;IACL,CAAC,EApCgB,KAAK,GAAL,gBAAK,KAAL,gBAAK,QAoCrB;AACL,CAAC,EA7CgB,UAAU,0BAAV,UAAU,QA6C1B"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { Diagnostic
|
|
1
|
+
import { Diagnostic } from './diagnostic';
|
|
2
|
+
import type { ts, tsc } from './typescript';
|
|
2
3
|
export declare class FluentDiagnostic extends Diagnostic {
|
|
4
|
+
readonly node: ts.Node;
|
|
3
5
|
constructor(node: ts.Node, message: string, { level, code }?: {
|
|
4
6
|
level?: Diagnostic.Level;
|
|
5
7
|
code?: number;
|
|
6
8
|
});
|
|
7
9
|
asTypeScriptDiagnostic(): tsc.Diagnostic;
|
|
8
10
|
}
|
|
9
|
-
export declare function findObjectPropertyValue(callExpression: ts.CallExpression, field: string): ts.Expression<ts.ts.Expression>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FluentDiagnostic = void 0;
|
|
4
|
+
const diagnostic_1 = require("./diagnostic");
|
|
5
|
+
class FluentDiagnostic extends diagnostic_1.Diagnostic {
|
|
6
|
+
node;
|
|
7
|
+
constructor(node, message, { level = diagnostic_1.Diagnostic.Level.Error, code = node.getKind() } = {}) {
|
|
8
|
+
super(message, node.getSourceFile(), { start: node.getStart(), end: node.getEnd() }, code, 'fluent', level);
|
|
9
|
+
this.node = node;
|
|
10
|
+
}
|
|
11
|
+
asTypeScriptDiagnostic() {
|
|
12
|
+
return {
|
|
13
|
+
messageText: this.message,
|
|
14
|
+
category: diagnostic_1.Diagnostic.Level.toCategory(this.level),
|
|
15
|
+
code: this.code,
|
|
16
|
+
file: this.file.compilerNode,
|
|
17
|
+
start: this.position.start,
|
|
18
|
+
length: this.position.end - this.position.start,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.FluentDiagnostic = FluentDiagnostic;
|
|
23
|
+
//# sourceMappingURL=fluent-diagnostic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fluent-diagnostic.js","sourceRoot":"","sources":["../src/fluent-diagnostic.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AAGzC,MAAa,gBAAiB,SAAQ,uBAAU;IAExB;IADpB,YACoB,IAAa,EAC7B,OAAe,EACf,EAAE,KAAK,GAAG,uBAAU,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,KAAkD,EAAE;QAE3G,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAA;QAJ3F,SAAI,GAAJ,IAAI,CAAS;IAKjC,CAAC;IAEe,sBAAsB;QAClC,OAAO;YACH,WAAW,EAAE,IAAI,CAAC,OAAO;YACzB,QAAQ,EAAE,uBAAU,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC;YACjD,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,YAAY;YAC5B,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK;YAC1B,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK;SAClD,CAAA;IACL,CAAC;CACJ;AAnBD,4CAmBC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ts } from './typescript';
|
|
2
|
+
type FluentDirective = '@fluent-ignore' | '@fluent-disable-sync' | '@fluent-disable-sync-for-file';
|
|
3
|
+
/**
|
|
4
|
+
* Determines if the specified node or any of its ancestors have the specified directive in
|
|
5
|
+
* one of their leading comment ranges. Avoids regex for optimal performance.
|
|
6
|
+
*/
|
|
7
|
+
export declare function hasDirective(node: ts.Node, directive: FluentDirective): boolean;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hasDirective = hasDirective;
|
|
4
|
+
const typescript_1 = require("./typescript");
|
|
5
|
+
const CACHE = new WeakMap();
|
|
6
|
+
function cacheGet(node) {
|
|
7
|
+
return CACHE.get(node) ?? CACHE.set(node, {}).get(node);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Determines if the specified node or any of its ancestors have the specified directive in
|
|
11
|
+
* one of their leading comment ranges. Avoids regex for optimal performance.
|
|
12
|
+
*/
|
|
13
|
+
function hasDirective(node, directive) {
|
|
14
|
+
const cache = cacheGet(node);
|
|
15
|
+
if (cache[directive] !== undefined) {
|
|
16
|
+
return cache[directive];
|
|
17
|
+
}
|
|
18
|
+
for (const comment of getComments(node)) {
|
|
19
|
+
const text = comment.getText();
|
|
20
|
+
const idx = text.indexOf(directive);
|
|
21
|
+
if (idx >= 0) {
|
|
22
|
+
return (cache[directive] =
|
|
23
|
+
isDirectiveBoundary(text.charCodeAt(idx - 1)) &&
|
|
24
|
+
isDirectiveBoundary(text.charCodeAt(idx + directive.length)));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const parent = node.getParent();
|
|
28
|
+
return (cache[directive] = !!parent && hasDirective(parent, directive));
|
|
29
|
+
}
|
|
30
|
+
function getComments(node) {
|
|
31
|
+
if (!typescript_1.ts.Node.isSourceFile(node)) {
|
|
32
|
+
return node.getLeadingCommentRanges();
|
|
33
|
+
}
|
|
34
|
+
const top = node.getFirstChildIfKind(typescript_1.ts.SyntaxKind.SyntaxList)?.getFirstChild();
|
|
35
|
+
return typescript_1.ts.Node.isCommentStatement(top) ? [top] : [];
|
|
36
|
+
}
|
|
37
|
+
const DIRECTIVE_CHARS = {
|
|
38
|
+
'-': (c) => c === 45,
|
|
39
|
+
'@': (c) => c === 64,
|
|
40
|
+
'A-Z': (c) => c >= 65 && c <= 90,
|
|
41
|
+
'a-z': (c) => c >= 97 && c <= 122,
|
|
42
|
+
};
|
|
43
|
+
function isDirectiveBoundary(code) {
|
|
44
|
+
if (isNaN(code)) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
for (const test of Object.values(DIRECTIVE_CHARS)) {
|
|
48
|
+
if (test(code)) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=fluent-directive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fluent-directive.js","sourceRoot":"","sources":["../src/fluent-directive.ts"],"names":[],"mappings":";;AAcA,oCAkBC;AAhCD,6CAAiC;AAKjC,MAAM,KAAK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AC,uBAAuB,EAAE,CAAA;IACzC,CAAC;IAED,MAAM,GAAG,GAAG,IAAI,CAAC,mBAAmB,CAAC,eAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,aAAa,EAAE,CAAA;IAC/E,OAAO,eAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;AACvD,CAAC;AAED,MAAM,eAAe,GAAG;IACpB,GAAG,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE;IAC5B,GAAG,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE;IAC5B,KAAK,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE;IACxC,KAAK,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,GAAG;CAC5C,CAAA;AAED,SAAS,mBAAmB,CAAC,IAAY;IACrC,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACd,OAAO,IAAI,CAAA;IACf,CAAC;IAED,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE,CAAC;QAChD,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACb,OAAO,KAAK,CAAA;QAChB,CAAC;IACL,CAAC;IAED,OAAO,IAAI,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ts } from './typescript';
|
|
2
|
+
import type { ProjectFile } from './plugins';
|
|
3
|
+
export declare const NOW_FILE_EXTENSION = ".now.ts";
|
|
4
|
+
export declare function isFluentNode(node: ts.Node): boolean;
|
|
5
|
+
export declare function isFluentFile(file: ts.SourceFile | ProjectFile | string): boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NOW_FILE_EXTENSION = void 0;
|
|
4
|
+
exports.isFluentNode = isFluentNode;
|
|
5
|
+
exports.isFluentFile = isFluentFile;
|
|
6
|
+
const typescript_1 = require("./typescript");
|
|
7
|
+
exports.NOW_FILE_EXTENSION = '.now.ts';
|
|
8
|
+
function isFluentNode(node) {
|
|
9
|
+
return isFluentFile(node.getSourceFile());
|
|
10
|
+
}
|
|
11
|
+
function isFluentFile(file) {
|
|
12
|
+
const path = typescript_1.ts.Node.isNode(file) ? file.getFilePath() : typeof file === 'string' ? file : file.getPath();
|
|
13
|
+
return path.endsWith(exports.NOW_FILE_EXTENSION);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=fluent-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fluent-file.js","sourceRoot":"","sources":["../src/fluent-file.ts"],"names":[],"mappings":";;;AAKA,oCAEC;AAED,oCAGC;AAZD,6CAAiC;AAGpB,QAAA,kBAAkB,GAAG,SAAS,CAAA;AAE3C,SAAgB,YAAY,CAAC,IAAa;IACtC,OAAO,YAAY,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAA;AAC7C,CAAC;AAED,SAAgB,YAAY,CAAC,IAA0C;IACnE,MAAM,IAAI,GAAG,eAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,CAAA;IACzG,OAAO,IAAI,CAAC,QAAQ,CAAC,0BAAkB,CAAC,CAAA;AAC5C,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FileSystem } from './fs';
|
|
2
|
+
import type { Options } from 'prettier';
|
|
3
|
+
export declare class Formatter {
|
|
4
|
+
private readonly fs;
|
|
5
|
+
private readonly cache;
|
|
6
|
+
constructor(fs: FileSystem);
|
|
7
|
+
resetCache(): void;
|
|
8
|
+
format(text: string, filePath: string): Promise<string>;
|
|
9
|
+
formatTypescript(text: string, options: Options): Promise<string>;
|
|
10
|
+
formatJson(jsonText: string, options: Options): string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
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.Formatter = void 0;
|
|
27
|
+
const typescriptPrettierPlugin = __importStar(require("prettier/plugins/typescript.js"));
|
|
28
|
+
const estreePrettierPlugin = __importStar(require("prettier/plugins/estree.js"));
|
|
29
|
+
const standalone_1 = require("prettier/standalone");
|
|
30
|
+
const path_1 = require("./path");
|
|
31
|
+
const config_loader_1 = require("./prettier/config-loader");
|
|
32
|
+
const json_1 = require("./json");
|
|
33
|
+
class Formatter {
|
|
34
|
+
fs;
|
|
35
|
+
cache = new Map();
|
|
36
|
+
constructor(fs) {
|
|
37
|
+
this.fs = fs;
|
|
38
|
+
}
|
|
39
|
+
resetCache() {
|
|
40
|
+
this.cache.clear();
|
|
41
|
+
}
|
|
42
|
+
async format(text, filePath) {
|
|
43
|
+
let config = await (0, config_loader_1.resolveConfig)(filePath, this.fs, this.cache);
|
|
44
|
+
if (!config) {
|
|
45
|
+
config = {
|
|
46
|
+
trailingComma: 'es5',
|
|
47
|
+
singleQuote: true,
|
|
48
|
+
printWidth: 120,
|
|
49
|
+
tabWidth: 4,
|
|
50
|
+
semi: false,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const ext = path_1.path.extname(filePath);
|
|
54
|
+
if (ext === '.json') {
|
|
55
|
+
return this.formatJson(text, config);
|
|
56
|
+
}
|
|
57
|
+
return this.formatTypescript(text, config);
|
|
58
|
+
}
|
|
59
|
+
async formatTypescript(text, options) {
|
|
60
|
+
return (0, standalone_1.format)(sanitizeText(text), {
|
|
61
|
+
plugins: [typescriptPrettierPlugin, estreePrettierPlugin],
|
|
62
|
+
parser: 'typescript',
|
|
63
|
+
...options,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
formatJson(jsonText, options) {
|
|
67
|
+
return JSON.stringify(json_1.JSON5.parse(jsonText), null, options.tabWidth ?? 2);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.Formatter = Formatter;
|
|
71
|
+
/**
|
|
72
|
+
* LS & PS characters are not supported by prettier, so replacing them with space
|
|
73
|
+
*/
|
|
74
|
+
function sanitizeText(fileText) {
|
|
75
|
+
return fileText.replace(/[\u2028\u2029]/g, ' ');
|
|
76
|
+
}
|
|
77
|
+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oBAAoB,CAAC;YACzD,MAAM,EAAE,YAAY;YACpB,GAAG,OAAO;SACb,CAAC,CAAA;IACN,CAAC;IAEM,UAAU,CAAC,QAAgB,EAAE,OAAgB;QAChD,OAAO,IAAI,CAAC,SAAS,CAAC,YAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAA;IAC7E,CAAC;CACJ;AAzCD,8BAyCC;AAED;;GAEG;AACH,SAAS,YAAY,CAAC,QAAgB;IAClC,OAAO,QAAQ,CAAC,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAA;AACnD,CAAC"}
|
package/dist/fs.d.ts
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { ts } from './typescript';
|
|
2
|
+
import * as fg from 'fast-glob';
|
|
3
|
+
import { Writable, Readable } from 'readable-stream';
|
|
4
|
+
/**
|
|
5
|
+
* A file system API based on a subset of the `fs` module from Node.js.
|
|
6
|
+
*/
|
|
7
|
+
export interface FileSystem {
|
|
8
|
+
/**
|
|
9
|
+
* Synchronously deletes the file or directory at the provided path.
|
|
10
|
+
*/
|
|
11
|
+
rmSync(path: string, options?: {
|
|
12
|
+
recursive?: boolean;
|
|
13
|
+
force?: boolean;
|
|
14
|
+
}): void;
|
|
15
|
+
/**
|
|
16
|
+
* Synchronously retrieves the status of the file or directory at the provided path.
|
|
17
|
+
*/
|
|
18
|
+
statSync(path: string): FileSystem.Stats;
|
|
19
|
+
/**
|
|
20
|
+
* Synchronously retrieves the status of the file or directory at the provided path. Does
|
|
21
|
+
* not dereference symbolic links.
|
|
22
|
+
*/
|
|
23
|
+
lstatSync(path: string): FileSystem.Stats;
|
|
24
|
+
/**
|
|
25
|
+
* Synchronously computes the canonical path by resolving `.`, `..` and symbolic links.
|
|
26
|
+
*/
|
|
27
|
+
realpathSync(path: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Synchronously creates a directory at the provided path.
|
|
30
|
+
*
|
|
31
|
+
* If `options.recursive` is `true`, the full path will be created including any missing
|
|
32
|
+
* parent directories, and the path of the first directory created will be returned.
|
|
33
|
+
* Otherwise, returns `undefined`.
|
|
34
|
+
*/
|
|
35
|
+
mkdirSync(path: string): void;
|
|
36
|
+
mkdirSync(path: string, options: {
|
|
37
|
+
recursive: true;
|
|
38
|
+
}): string | undefined;
|
|
39
|
+
mkdirSync(path: string, options?: {
|
|
40
|
+
recursive: boolean;
|
|
41
|
+
}): string | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Synchronously renames the file or directory at the old path to the new path.
|
|
44
|
+
*/
|
|
45
|
+
renameSync(oldPath: string, newPath: string): void;
|
|
46
|
+
/**
|
|
47
|
+
* Synchronously reads the contents of the directory at the provided path.
|
|
48
|
+
*
|
|
49
|
+
* If `options.withFileTypes` is `true`, returns the contents as an array of `Entry`
|
|
50
|
+
* objects. Otherwise, returns the contents as an array of strings containing the names
|
|
51
|
+
* of each entry.
|
|
52
|
+
*/
|
|
53
|
+
readdirSync(path: string): string[];
|
|
54
|
+
readdirSync(path: string, options: {
|
|
55
|
+
withFileTypes: true;
|
|
56
|
+
}): FileSystem.Entry[];
|
|
57
|
+
readdirSync(path: string, options?: {
|
|
58
|
+
withFileTypes: boolean;
|
|
59
|
+
}): string[] | FileSystem.Entry[];
|
|
60
|
+
/**
|
|
61
|
+
* Synchronously reads the contents of the file at the provided path.
|
|
62
|
+
*
|
|
63
|
+
* If `options.encoding` is provided, the contents will be returned as a string. Otherwise,
|
|
64
|
+
* the contents will be returned as a `Buffer`.
|
|
65
|
+
*/
|
|
66
|
+
readFileSync(path: string, options?: {
|
|
67
|
+
flag: 'r';
|
|
68
|
+
}): Buffer;
|
|
69
|
+
readFileSync(path: string, options: {
|
|
70
|
+
encoding: FileSystem.Encoding;
|
|
71
|
+
flag?: 'r';
|
|
72
|
+
}): string;
|
|
73
|
+
readFileSync(path: string, options?: {
|
|
74
|
+
encoding?: FileSystem.Encoding;
|
|
75
|
+
flag?: 'r';
|
|
76
|
+
}): string | Buffer;
|
|
77
|
+
/**
|
|
78
|
+
* Synchronously writes the provided content to the file at the provided path.
|
|
79
|
+
*/
|
|
80
|
+
writeFileSync(path: string, content: string | NodeJS.ArrayBufferView, options?: {
|
|
81
|
+
encoding: FileSystem.Encoding;
|
|
82
|
+
}): void;
|
|
83
|
+
/**
|
|
84
|
+
* Synchronously copies the file at the source path to the destination path.
|
|
85
|
+
*/
|
|
86
|
+
copyFileSync(srcPath: string, destPath: string): void;
|
|
87
|
+
/**
|
|
88
|
+
* Synchronously checks if the file or directory at the provided path is accessible. If it
|
|
89
|
+
* is accessible, the method does nothing. If it is not accessible, an error is thrown.
|
|
90
|
+
*/
|
|
91
|
+
accessSync(path: string): void;
|
|
92
|
+
}
|
|
93
|
+
export declare namespace FileSystem {
|
|
94
|
+
type Entry = {
|
|
95
|
+
name: string;
|
|
96
|
+
isFile(): boolean;
|
|
97
|
+
isDirectory(): boolean;
|
|
98
|
+
isSymbolicLink(): boolean;
|
|
99
|
+
isCharacterDevice(): boolean;
|
|
100
|
+
isBlockDevice(): boolean;
|
|
101
|
+
isSocket(): boolean;
|
|
102
|
+
isFIFO(): boolean;
|
|
103
|
+
};
|
|
104
|
+
type Stats = {
|
|
105
|
+
isFile(): boolean;
|
|
106
|
+
isDirectory(): boolean;
|
|
107
|
+
isSymbolicLink(): boolean;
|
|
108
|
+
isCharacterDevice(): boolean;
|
|
109
|
+
isBlockDevice(): boolean;
|
|
110
|
+
isSocket(): boolean;
|
|
111
|
+
isFIFO(): boolean;
|
|
112
|
+
};
|
|
113
|
+
type Encoding = 'utf-8' | 'binary';
|
|
114
|
+
/**
|
|
115
|
+
* Synchronously copies the file or directory at the source path to the destination
|
|
116
|
+
* path. If the source path is a directory, only its contents will be copied, not the
|
|
117
|
+
* directory itself. If the source path is a file, the destination path cannot be a
|
|
118
|
+
* directory.
|
|
119
|
+
*
|
|
120
|
+
* If `options.filter` is provided, only entries for which the filter returns `true`
|
|
121
|
+
* will be copied.
|
|
122
|
+
*/
|
|
123
|
+
function copySync(fs: FileSystem, srcPath: string, destPath: string, options?: {
|
|
124
|
+
filter(src: string): boolean;
|
|
125
|
+
}): void;
|
|
126
|
+
/**
|
|
127
|
+
* Synchronously checks if the file or directory at the provided path exists.
|
|
128
|
+
*/
|
|
129
|
+
function existsSync(fs: FileSystem, path: string): boolean;
|
|
130
|
+
function ensureDirSync(fs: FileSystem, path: string): void;
|
|
131
|
+
/**
|
|
132
|
+
* Provides an implementation of a write stream for FileSystems that don't
|
|
133
|
+
* have one natively. Buffers all chunks in memory until finalized.
|
|
134
|
+
*/
|
|
135
|
+
function createWriteStream(fs: FileSystem, path: string): Writable;
|
|
136
|
+
/**
|
|
137
|
+
* Provides an implementation of a read stream for FileSystems that don't
|
|
138
|
+
* have one natively. Reads the entire content as a single chunk.
|
|
139
|
+
*/
|
|
140
|
+
function createReadStream(fs: FileSystem, path: string): Readable;
|
|
141
|
+
function traverseDirectory(fs: FileSystem, dir: string, options: {
|
|
142
|
+
extensions?: string[];
|
|
143
|
+
ignore_extensions?: string[] | undefined;
|
|
144
|
+
visitor: (filePath: string) => void;
|
|
145
|
+
}): void;
|
|
146
|
+
}
|
|
147
|
+
export declare class TsMorphFileSystemWrapper implements ts.FileSystemHost {
|
|
148
|
+
#private;
|
|
149
|
+
private readonly fs;
|
|
150
|
+
static ENOENT: string;
|
|
151
|
+
constructor(fs: FileSystem);
|
|
152
|
+
deleteSync(path: string): void;
|
|
153
|
+
readFileSync(path: string, encoding?: FileSystem.Encoding): string;
|
|
154
|
+
writeFileSync(path: string, text: string): void;
|
|
155
|
+
mkdirSync(path: string): void;
|
|
156
|
+
moveSync(srcPath: string, destPath: string): void;
|
|
157
|
+
copySync(srcPath: string, destPath: string): void;
|
|
158
|
+
fileExistsSync(path: string): boolean;
|
|
159
|
+
directoryExistsSync(path: string): boolean;
|
|
160
|
+
readDirSync(dir: string): ts.RuntimeDirEntry[];
|
|
161
|
+
globSync(patterns: string[], opts?: fg.Options): string[];
|
|
162
|
+
realpathSync(path: string): string;
|
|
163
|
+
getCurrentDirectory(): string;
|
|
164
|
+
isCaseSensitive(): boolean;
|
|
165
|
+
delete(path: string): Promise<void>;
|
|
166
|
+
readFile(path: string, encoding?: FileSystem.Encoding): Promise<string>;
|
|
167
|
+
writeFile(path: string, text: string): Promise<void>;
|
|
168
|
+
mkdir(path: string): Promise<void>;
|
|
169
|
+
move(srcPath: string, destPath: string): Promise<void>;
|
|
170
|
+
copy(srcPath: string, destPath: string): Promise<void>;
|
|
171
|
+
fileExists(path: string): Promise<boolean>;
|
|
172
|
+
directoryExists(path: string): Promise<boolean>;
|
|
173
|
+
glob(patterns: string[]): Promise<string[]>;
|
|
174
|
+
}
|