@messagevisor/core 0.0.1 → 0.1.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/CHANGELOG.md +16 -0
- package/LICENSE +21 -0
- package/README.md +7 -0
- package/jest.config.js +8 -0
- package/lib/benchmark/index.d.ts +2 -0
- package/lib/benchmark/index.js +417 -0
- package/lib/benchmark/index.js.map +1 -0
- package/lib/builder/index.d.ts +70 -0
- package/lib/builder/index.js +831 -0
- package/lib/builder/index.js.map +1 -0
- package/lib/cli/index.d.ts +28 -0
- package/lib/cli/index.js +182 -0
- package/lib/cli/index.js.map +1 -0
- package/lib/config/index.d.ts +61 -0
- package/lib/config/index.js +255 -0
- package/lib/config/index.js.map +1 -0
- package/lib/create/index.d.ts +2 -0
- package/lib/create/index.js +405 -0
- package/lib/create/index.js.map +1 -0
- package/lib/datasource/filesystemAdapter.d.ts +44 -0
- package/lib/datasource/filesystemAdapter.js +424 -0
- package/lib/datasource/filesystemAdapter.js.map +1 -0
- package/lib/datasource/index.d.ts +39 -0
- package/lib/datasource/index.js +96 -0
- package/lib/datasource/index.js.map +1 -0
- package/lib/error.d.ts +6 -0
- package/lib/error.js +49 -0
- package/lib/error.js.map +1 -0
- package/lib/evaluate/cli.d.ts +8 -0
- package/lib/evaluate/cli.js +179 -0
- package/lib/evaluate/cli.js.map +1 -0
- package/lib/evaluate/index.d.ts +10 -0
- package/lib/evaluate/index.js +131 -0
- package/lib/evaluate/index.js.map +1 -0
- package/lib/examples/coerceExampleIsoDates.d.ts +12 -0
- package/lib/examples/coerceExampleIsoDates.js +81 -0
- package/lib/examples/coerceExampleIsoDates.js.map +1 -0
- package/lib/examples/index.d.ts +63 -0
- package/lib/examples/index.js +713 -0
- package/lib/examples/index.js.map +1 -0
- package/lib/exporter/index.d.ts +60 -0
- package/lib/exporter/index.js +610 -0
- package/lib/exporter/index.js.map +1 -0
- package/lib/find-duplicates/index.d.ts +41 -0
- package/lib/find-duplicates/index.js +297 -0
- package/lib/find-duplicates/index.js.map +1 -0
- package/lib/generate-code/index.d.ts +11 -0
- package/lib/generate-code/index.js +157 -0
- package/lib/generate-code/index.js.map +1 -0
- package/lib/generate-code/typescript.d.ts +14 -0
- package/lib/generate-code/typescript.js +307 -0
- package/lib/generate-code/typescript.js.map +1 -0
- package/lib/importer/index.d.ts +64 -0
- package/lib/importer/index.js +1092 -0
- package/lib/importer/index.js.map +1 -0
- package/lib/index.d.ts +18 -0
- package/lib/index.js +35 -0
- package/lib/index.js.map +1 -0
- package/lib/info/index.d.ts +17 -0
- package/lib/info/index.js +132 -0
- package/lib/info/index.js.map +1 -0
- package/lib/init/index.d.ts +30 -0
- package/lib/init/index.js +348 -0
- package/lib/init/index.js.map +1 -0
- package/lib/lint/index.d.ts +1 -0
- package/lib/lint/index.js +6 -0
- package/lib/lint/index.js.map +1 -0
- package/lib/linter/attributeSchema.d.ts +7 -0
- package/lib/linter/attributeSchema.js +36 -0
- package/lib/linter/attributeSchema.js.map +1 -0
- package/lib/linter/checkLocaleCircularDependency.d.ts +7 -0
- package/lib/linter/checkLocaleCircularDependency.js +42 -0
- package/lib/linter/checkLocaleCircularDependency.js.map +1 -0
- package/lib/linter/conditionSchema.d.ts +3 -0
- package/lib/linter/conditionSchema.js +283 -0
- package/lib/linter/conditionSchema.js.map +1 -0
- package/lib/linter/formatSchema.d.ts +325 -0
- package/lib/linter/formatSchema.js +165 -0
- package/lib/linter/formatSchema.js.map +1 -0
- package/lib/linter/icuStyleLint.d.ts +6 -0
- package/lib/linter/icuStyleLint.js +226 -0
- package/lib/linter/icuStyleLint.js.map +1 -0
- package/lib/linter/index.d.ts +34 -0
- package/lib/linter/index.js +557 -0
- package/lib/linter/index.js.map +1 -0
- package/lib/linter/localeSchema.d.ts +672 -0
- package/lib/linter/localeSchema.js +50 -0
- package/lib/linter/localeSchema.js.map +1 -0
- package/lib/linter/messageSchema.d.ts +35 -0
- package/lib/linter/messageSchema.js +115 -0
- package/lib/linter/messageSchema.js.map +1 -0
- package/lib/linter/printError.d.ts +8 -0
- package/lib/linter/printError.js +41 -0
- package/lib/linter/printError.js.map +1 -0
- package/lib/linter/schema.d.ts +33 -0
- package/lib/linter/schema.js +192 -0
- package/lib/linter/schema.js.map +1 -0
- package/lib/linter/segmentSchema.d.ts +8 -0
- package/lib/linter/segmentSchema.js +18 -0
- package/lib/linter/segmentSchema.js.map +1 -0
- package/lib/linter/targetSchema.d.ts +337 -0
- package/lib/linter/targetSchema.js +39 -0
- package/lib/linter/targetSchema.js.map +1 -0
- package/lib/linter/testSchema.d.ts +71 -0
- package/lib/linter/testSchema.js +165 -0
- package/lib/linter/testSchema.js.map +1 -0
- package/lib/linter/zodHelpers.d.ts +2 -0
- package/lib/linter/zodHelpers.js +15 -0
- package/lib/linter/zodHelpers.js.map +1 -0
- package/lib/list/index.d.ts +8 -0
- package/lib/list/index.js +524 -0
- package/lib/list/index.js.map +1 -0
- package/lib/matrix.d.ts +4 -0
- package/lib/matrix.js +66 -0
- package/lib/matrix.js.map +1 -0
- package/lib/promoter/index.d.ts +65 -0
- package/lib/promoter/index.js +1208 -0
- package/lib/promoter/index.js.map +1 -0
- package/lib/prune/index.d.ts +37 -0
- package/lib/prune/index.js +673 -0
- package/lib/prune/index.js.map +1 -0
- package/lib/sets.d.ts +10 -0
- package/lib/sets.js +120 -0
- package/lib/sets.js.map +1 -0
- package/lib/tester/cliFormat.d.ts +8 -0
- package/lib/tester/cliFormat.js +15 -0
- package/lib/tester/cliFormat.js.map +1 -0
- package/lib/tester/index.d.ts +35 -0
- package/lib/tester/index.js +713 -0
- package/lib/tester/index.js.map +1 -0
- package/lib/tester/matrix.d.ts +14 -0
- package/lib/tester/matrix.js +76 -0
- package/lib/tester/matrix.js.map +1 -0
- package/lib/tester/prettyDuration.d.ts +1 -0
- package/lib/tester/prettyDuration.js +30 -0
- package/lib/tester/prettyDuration.js.map +1 -0
- package/lib/tester/printTestResult.d.ts +2 -0
- package/lib/tester/printTestResult.js +32 -0
- package/lib/tester/printTestResult.js.map +1 -0
- package/lib/tester/types.d.ts +29 -0
- package/lib/tester/types.js +3 -0
- package/lib/tester/types.js.map +1 -0
- package/package.json +41 -13
- package/src/benchmark/index.spec.ts +375 -0
- package/src/benchmark/index.ts +433 -0
- package/src/builder/index.spec.ts +822 -0
- package/src/builder/index.ts +920 -0
- package/src/cli/index.spec.ts +54 -0
- package/src/cli/index.ts +150 -0
- package/src/config/index.spec.ts +70 -0
- package/src/config/index.ts +259 -0
- package/src/create/index.spec.ts +272 -0
- package/src/create/index.ts +295 -0
- package/src/datasource/filesystemAdapter.ts +313 -0
- package/src/datasource/index.ts +135 -0
- package/src/error.ts +33 -0
- package/src/evaluate/cli.spec.ts +368 -0
- package/src/evaluate/cli.ts +130 -0
- package/src/evaluate/index.ts +161 -0
- package/src/examples/coerceExampleIsoDates.spec.ts +81 -0
- package/src/examples/coerceExampleIsoDates.ts +98 -0
- package/src/examples/index.spec.ts +453 -0
- package/src/examples/index.ts +854 -0
- package/src/exporter/index.spec.ts +443 -0
- package/src/exporter/index.ts +643 -0
- package/src/find-duplicates/index.spec.ts +289 -0
- package/src/find-duplicates/index.ts +314 -0
- package/src/generate-code/index.ts +92 -0
- package/src/generate-code/typescript.spec.ts +241 -0
- package/src/generate-code/typescript.ts +284 -0
- package/src/importer/index.spec.ts +1101 -0
- package/src/importer/index.ts +1190 -0
- package/src/index.ts +18 -0
- package/src/info/index.ts +67 -0
- package/src/init/index.spec.ts +279 -0
- package/src/init/index.ts +292 -0
- package/src/lint/index.ts +1 -0
- package/src/linter/attributeSchema.ts +38 -0
- package/src/linter/checkLocaleCircularDependency.ts +51 -0
- package/src/linter/conditionSchema.ts +386 -0
- package/src/linter/formatSchema.ts +170 -0
- package/src/linter/icuStyleLint.ts +312 -0
- package/src/linter/index.spec.ts +824 -0
- package/src/linter/index.ts +460 -0
- package/src/linter/localeSchema.ts +70 -0
- package/src/linter/messageSchema.ts +152 -0
- package/src/linter/printError.ts +52 -0
- package/src/linter/schema.ts +230 -0
- package/src/linter/segmentSchema.ts +15 -0
- package/src/linter/targetSchema.ts +50 -0
- package/src/linter/testSchema.spec.ts +405 -0
- package/src/linter/testSchema.ts +239 -0
- package/src/linter/zodHelpers.ts +16 -0
- package/src/list/index.spec.ts +431 -0
- package/src/list/index.ts +463 -0
- package/src/matrix.ts +69 -0
- package/src/promoter/index.spec.ts +584 -0
- package/src/promoter/index.ts +1267 -0
- package/src/prune/index.spec.ts +418 -0
- package/src/prune/index.ts +693 -0
- package/src/sets.ts +74 -0
- package/src/tester/cliFormat.ts +11 -0
- package/src/tester/featurevisorIntegration.spec.ts +101 -0
- package/src/tester/index.spec.ts +577 -0
- package/src/tester/index.ts +679 -0
- package/src/tester/matrix.ts +106 -0
- package/src/tester/prettyDuration.ts +34 -0
- package/src/tester/printTestResult.ts +40 -0
- package/src/tester/types.ts +32 -0
- package/tsconfig.cjs.json +11 -0
- package/tsconfig.typecheck.json +4 -0
|
@@ -0,0 +1,348 @@
|
|
|
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 () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
45
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
46
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
47
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
48
|
+
function step(op) {
|
|
49
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
50
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
51
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
52
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
53
|
+
switch (op[0]) {
|
|
54
|
+
case 0: case 1: t = op; break;
|
|
55
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
56
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
57
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
58
|
+
default:
|
|
59
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
60
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
61
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
62
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
63
|
+
if (t[2]) _.ops.pop();
|
|
64
|
+
_.trys.pop(); continue;
|
|
65
|
+
}
|
|
66
|
+
op = body.call(thisArg, _);
|
|
67
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
68
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
72
|
+
exports.initPlugin = exports.EXAMPLES_TAR_URL = exports.EXAMPLES_BRANCH_NAME = exports.EXAMPLES_REPO_NAME = exports.EXAMPLES_ORG_NAME = exports.DEFAULT_PROJECT = void 0;
|
|
73
|
+
exports.initProject = initProject;
|
|
74
|
+
exports.initProjectFromCLI = initProjectFromCLI;
|
|
75
|
+
var fs = __importStar(require("fs"));
|
|
76
|
+
var path = __importStar(require("path"));
|
|
77
|
+
var promises_1 = require("readline/promises");
|
|
78
|
+
var stream_1 = require("stream");
|
|
79
|
+
var error_1 = require("../error");
|
|
80
|
+
var tar = require("tar");
|
|
81
|
+
exports.DEFAULT_PROJECT = "yml";
|
|
82
|
+
exports.EXAMPLES_ORG_NAME = "messagevisor";
|
|
83
|
+
exports.EXAMPLES_REPO_NAME = "messagevisor";
|
|
84
|
+
exports.EXAMPLES_BRANCH_NAME = "main";
|
|
85
|
+
exports.EXAMPLES_TAR_URL = "https://codeload.github.com/".concat(exports.EXAMPLES_ORG_NAME, "/").concat(exports.EXAMPLES_REPO_NAME, "/tar.gz/").concat(exports.EXAMPLES_BRANCH_NAME);
|
|
86
|
+
function getProjectArchivePath(projectName) {
|
|
87
|
+
return "".concat(exports.EXAMPLES_REPO_NAME, "-").concat(exports.EXAMPLES_BRANCH_NAME, "/projects/project-").concat(projectName, "/");
|
|
88
|
+
}
|
|
89
|
+
function getExcludedReason(relativePath) {
|
|
90
|
+
var normalized = relativePath.replace(/\\/g, "/").replace(/\/+$/, "");
|
|
91
|
+
if (!normalized) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
var topLevelName = normalized.split("/")[0];
|
|
95
|
+
if (["datafiles", "catalog", "exports", "imports", "node_modules"].includes(topLevelName)) {
|
|
96
|
+
return "generated";
|
|
97
|
+
}
|
|
98
|
+
if (normalized === ".DS_Store" || normalized.endsWith("/.DS_Store")) {
|
|
99
|
+
return "generated";
|
|
100
|
+
}
|
|
101
|
+
if (normalized === ".messagevisor/REVISION" ||
|
|
102
|
+
normalized.startsWith(".messagevisor/promotions/") ||
|
|
103
|
+
normalized.startsWith(".messagevisor/memory/") ||
|
|
104
|
+
/^\.messagevisor\/sets\/[^/]+\/REVISION$/.test(normalized)) {
|
|
105
|
+
return "generated";
|
|
106
|
+
}
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
function assertDestinationReady(directoryPath, overwrite) {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
111
|
+
var entries;
|
|
112
|
+
return __generator(this, function (_a) {
|
|
113
|
+
switch (_a.label) {
|
|
114
|
+
case 0: return [4 /*yield*/, fs.promises.mkdir(directoryPath, { recursive: true })];
|
|
115
|
+
case 1:
|
|
116
|
+
_a.sent();
|
|
117
|
+
return [4 /*yield*/, fs.promises.readdir(directoryPath)];
|
|
118
|
+
case 2:
|
|
119
|
+
entries = _a.sent();
|
|
120
|
+
if (entries.length > 0 && !overwrite) {
|
|
121
|
+
throw new error_1.MessagevisorCLIError("Destination directory is not empty: ".concat(directoryPath, ". Pass --overwrite to initialize there and skip conflicting files."));
|
|
122
|
+
}
|
|
123
|
+
return [2 /*return*/];
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
function isDirectoryEmpty(directoryPath) {
|
|
129
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
130
|
+
var entries;
|
|
131
|
+
return __generator(this, function (_a) {
|
|
132
|
+
switch (_a.label) {
|
|
133
|
+
case 0: return [4 /*yield*/, fs.promises.mkdir(directoryPath, { recursive: true })];
|
|
134
|
+
case 1:
|
|
135
|
+
_a.sent();
|
|
136
|
+
return [4 /*yield*/, fs.promises.readdir(directoryPath)];
|
|
137
|
+
case 2:
|
|
138
|
+
entries = _a.sent();
|
|
139
|
+
return [2 /*return*/, entries.length === 0];
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
function getInitProjectOptions(options) {
|
|
145
|
+
return {
|
|
146
|
+
overwrite: options.overwrite,
|
|
147
|
+
tarballUrl: options.tarballUrl,
|
|
148
|
+
tarballPath: options.tarballPath,
|
|
149
|
+
fetchImpl: options.fetchImpl,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function validateNewDirectoryName(directoryName) {
|
|
153
|
+
var trimmed = directoryName.trim();
|
|
154
|
+
if (!trimmed) {
|
|
155
|
+
throw new error_1.MessagevisorCLIError("Directory name is required to initialize a new Messagevisor project.");
|
|
156
|
+
}
|
|
157
|
+
if (path.isAbsolute(trimmed) ||
|
|
158
|
+
trimmed.includes("/") ||
|
|
159
|
+
trimmed.includes("\\") ||
|
|
160
|
+
trimmed === "." ||
|
|
161
|
+
trimmed === "..") {
|
|
162
|
+
throw new error_1.MessagevisorCLIError("Directory name must be a simple folder name, not an absolute path or nested path.");
|
|
163
|
+
}
|
|
164
|
+
return trimmed;
|
|
165
|
+
}
|
|
166
|
+
function promptForNewDirectoryName(message, options) {
|
|
167
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
168
|
+
var input, output, canPrompt, readline;
|
|
169
|
+
return __generator(this, function (_a) {
|
|
170
|
+
if (options.promptDirectoryName) {
|
|
171
|
+
return [2 /*return*/, options.promptDirectoryName(message)];
|
|
172
|
+
}
|
|
173
|
+
input = options.input || process.stdin;
|
|
174
|
+
output = options.output || process.stdout;
|
|
175
|
+
canPrompt = input.isTTY !== false && output.isTTY !== false;
|
|
176
|
+
if (!canPrompt) {
|
|
177
|
+
throw new error_1.MessagevisorCLIError("Current working directory is not empty. Run `messagevisor init` from an empty directory, or pass --overwrite.");
|
|
178
|
+
}
|
|
179
|
+
readline = (0, promises_1.createInterface)({ input: input, output: output });
|
|
180
|
+
try {
|
|
181
|
+
return [2 /*return*/, readline.question(message)];
|
|
182
|
+
}
|
|
183
|
+
finally {
|
|
184
|
+
readline.close();
|
|
185
|
+
}
|
|
186
|
+
return [2 /*return*/];
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
function getTarballStream() {
|
|
191
|
+
return __awaiter(this, arguments, void 0, function (options) {
|
|
192
|
+
var fetchImpl, response;
|
|
193
|
+
if (options === void 0) { options = {}; }
|
|
194
|
+
return __generator(this, function (_a) {
|
|
195
|
+
switch (_a.label) {
|
|
196
|
+
case 0:
|
|
197
|
+
if (options.tarballPath) {
|
|
198
|
+
return [2 /*return*/, fs.createReadStream(options.tarballPath)];
|
|
199
|
+
}
|
|
200
|
+
fetchImpl = options.fetchImpl || fetch;
|
|
201
|
+
return [4 /*yield*/, fetchImpl(options.tarballUrl || exports.EXAMPLES_TAR_URL)];
|
|
202
|
+
case 1:
|
|
203
|
+
response = _a.sent();
|
|
204
|
+
if (!response.ok || !response.body) {
|
|
205
|
+
throw new Error("Unable to download Messagevisor examples tarball: ".concat(response.status, " ").concat(response.statusText));
|
|
206
|
+
}
|
|
207
|
+
return [2 /*return*/, stream_1.Readable.fromWeb(response.body)];
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
function initProject(directoryPath_1) {
|
|
213
|
+
return __awaiter(this, arguments, void 0, function (directoryPath, projectName, options) {
|
|
214
|
+
var tarballStream, projectArchivePath, createdFileCount, skippedConflictCount, matchedProjectPath;
|
|
215
|
+
if (projectName === void 0) { projectName = exports.DEFAULT_PROJECT; }
|
|
216
|
+
if (options === void 0) { options = {}; }
|
|
217
|
+
return __generator(this, function (_a) {
|
|
218
|
+
switch (_a.label) {
|
|
219
|
+
case 0: return [4 /*yield*/, assertDestinationReady(directoryPath, options.overwrite)];
|
|
220
|
+
case 1:
|
|
221
|
+
_a.sent();
|
|
222
|
+
return [4 /*yield*/, getTarballStream(options)];
|
|
223
|
+
case 2:
|
|
224
|
+
tarballStream = _a.sent();
|
|
225
|
+
projectArchivePath = getProjectArchivePath(projectName);
|
|
226
|
+
createdFileCount = 0;
|
|
227
|
+
skippedConflictCount = 0;
|
|
228
|
+
matchedProjectPath = false;
|
|
229
|
+
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
230
|
+
tarballStream
|
|
231
|
+
.pipe(tar.x({
|
|
232
|
+
cwd: directoryPath,
|
|
233
|
+
strip: 3,
|
|
234
|
+
filter: function (archivePath, entry) {
|
|
235
|
+
if (!archivePath.startsWith(projectArchivePath)) {
|
|
236
|
+
return false;
|
|
237
|
+
}
|
|
238
|
+
matchedProjectPath = true;
|
|
239
|
+
var relativePath = archivePath.slice(projectArchivePath.length);
|
|
240
|
+
if (!relativePath) {
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
if (getExcludedReason(relativePath)) {
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
246
|
+
var destinationPath = path.join(directoryPath, relativePath);
|
|
247
|
+
var entryType = entry.type;
|
|
248
|
+
if (entryType !== "Directory" && fs.existsSync(destinationPath)) {
|
|
249
|
+
skippedConflictCount += 1;
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
if (entryType !== "Directory") {
|
|
253
|
+
createdFileCount += 1;
|
|
254
|
+
}
|
|
255
|
+
return true;
|
|
256
|
+
},
|
|
257
|
+
}))
|
|
258
|
+
.on("error", reject)
|
|
259
|
+
.on("finish", resolve);
|
|
260
|
+
})];
|
|
261
|
+
case 3:
|
|
262
|
+
_a.sent();
|
|
263
|
+
if (!matchedProjectPath) {
|
|
264
|
+
throw new error_1.MessagevisorCLIError("Unknown project \"".concat(projectName, "\". No matching project-").concat(projectName, " found in examples tarball."));
|
|
265
|
+
}
|
|
266
|
+
return [2 /*return*/, {
|
|
267
|
+
project: projectName,
|
|
268
|
+
destinationDirectoryPath: directoryPath,
|
|
269
|
+
createdFileCount: createdFileCount,
|
|
270
|
+
skippedConflictCount: skippedConflictCount,
|
|
271
|
+
}];
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
function initProjectFromCLI(rootDirectoryPath_1) {
|
|
277
|
+
return __awaiter(this, arguments, void 0, function (rootDirectoryPath, projectName, options) {
|
|
278
|
+
var _a, directoryName, _b, destinationDirectoryPath;
|
|
279
|
+
if (projectName === void 0) { projectName = exports.DEFAULT_PROJECT; }
|
|
280
|
+
if (options === void 0) { options = {}; }
|
|
281
|
+
return __generator(this, function (_c) {
|
|
282
|
+
switch (_c.label) {
|
|
283
|
+
case 0:
|
|
284
|
+
_a = options.overwrite;
|
|
285
|
+
if (_a) return [3 /*break*/, 2];
|
|
286
|
+
return [4 /*yield*/, isDirectoryEmpty(rootDirectoryPath)];
|
|
287
|
+
case 1:
|
|
288
|
+
_a = (_c.sent());
|
|
289
|
+
_c.label = 2;
|
|
290
|
+
case 2:
|
|
291
|
+
if (_a) {
|
|
292
|
+
return [2 /*return*/, initProject(rootDirectoryPath, projectName, getInitProjectOptions(options))];
|
|
293
|
+
}
|
|
294
|
+
_b = validateNewDirectoryName;
|
|
295
|
+
return [4 /*yield*/, promptForNewDirectoryName("Current working directory is not empty: ".concat(rootDirectoryPath, "\nEnter a new directory name to initialize Messagevisor project: "), options)];
|
|
296
|
+
case 3:
|
|
297
|
+
directoryName = _b.apply(void 0, [_c.sent()]);
|
|
298
|
+
destinationDirectoryPath = path.join(rootDirectoryPath, directoryName);
|
|
299
|
+
return [4 /*yield*/, isDirectoryEmpty(destinationDirectoryPath)];
|
|
300
|
+
case 4:
|
|
301
|
+
if (!(_c.sent())) {
|
|
302
|
+
throw new error_1.MessagevisorCLIError("Destination directory is not empty: ".concat(destinationDirectoryPath, ". Please choose a different directory name."));
|
|
303
|
+
}
|
|
304
|
+
return [2 /*return*/, initProject(destinationDirectoryPath, projectName, getInitProjectOptions(options))];
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
exports.initPlugin = {
|
|
310
|
+
command: "init",
|
|
311
|
+
handler: function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
312
|
+
var result;
|
|
313
|
+
var rootDirectoryPath = _b.rootDirectoryPath, parsed = _b.parsed;
|
|
314
|
+
return __generator(this, function (_c) {
|
|
315
|
+
switch (_c.label) {
|
|
316
|
+
case 0: return [4 /*yield*/, initProjectFromCLI(rootDirectoryPath, parsed.project || exports.DEFAULT_PROJECT, {
|
|
317
|
+
overwrite: parsed.overwrite === true,
|
|
318
|
+
})];
|
|
319
|
+
case 1:
|
|
320
|
+
result = _c.sent();
|
|
321
|
+
console.log("Initialized Messagevisor project from \"".concat(result.project, "\""));
|
|
322
|
+
console.log("Destination directory: ".concat(result.destinationDirectoryPath));
|
|
323
|
+
console.log("Created files: ".concat(result.createdFileCount));
|
|
324
|
+
if (result.skippedConflictCount > 0) {
|
|
325
|
+
console.log("Skipped conflicts: ".concat(result.skippedConflictCount));
|
|
326
|
+
}
|
|
327
|
+
console.log("");
|
|
328
|
+
console.log("Please run \"npm install\" in this directory.");
|
|
329
|
+
return [2 /*return*/];
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
}); },
|
|
333
|
+
examples: [
|
|
334
|
+
{
|
|
335
|
+
command: "init",
|
|
336
|
+
description: "initialize a Messagevisor project from the default yml starter",
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
command: "init --project=json",
|
|
340
|
+
description: "initialize a Messagevisor project from the json starter",
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
command: "init --project=environments",
|
|
344
|
+
description: "initialize a Messagevisor project from the sets-based environments starter",
|
|
345
|
+
},
|
|
346
|
+
],
|
|
347
|
+
};
|
|
348
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/init/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoKA,kCAmEC;AAED,gDAwBC;AAjQD,qCAAyB;AACzB,yCAA6B;AAC7B,8CAAoD;AACpD,iCAAkC;AAGlC,kCAAgD;AAEhD,IAAM,GAAG,GAAQ,OAAO,CAAC,KAAK,CAAC,CAAC;AAEnB,QAAA,eAAe,GAAG,KAAK,CAAC;AACxB,QAAA,iBAAiB,GAAG,cAAc,CAAC;AACnC,QAAA,kBAAkB,GAAG,cAAc,CAAC;AACpC,QAAA,oBAAoB,GAAG,MAAM,CAAC;AAC9B,QAAA,gBAAgB,GAAG,sCAA+B,yBAAiB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GAAG,CAAC,+CAA6C,CAAC,CAAC;;;;SAC5D;IACD,QAAQ,EAAE;QACR;YACE,OAAO,EAAE,MAAM;YACf,WAAW,EAAE,gEAAgE;SAC9E;QACD;YACE,OAAO,EAAE,qBAAqB;YAC9B,WAAW,EAAE,yDAAyD;SACvE;QACD;YACE,OAAO,EAAE,6BAA6B;YACtC,WAAW,EAAE,4EAA4E;SAC1F;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { lintPlugin } from "../linter";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.lintPlugin = void 0;
|
|
4
|
+
var linter_1 = require("../linter");
|
|
5
|
+
Object.defineProperty(exports, "lintPlugin", { enumerable: true, get: function () { return linter_1.lintPlugin; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lint/index.ts"],"names":[],"mappings":";;;AAAA,oCAAuC;AAA9B,oGAAA,UAAU,OAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare function getAttributeZodSchema(): z.ZodIntersection<z.ZodType<any, unknown, z.core.$ZodTypeInternals<any, unknown>>, z.ZodObject<{
|
|
3
|
+
key: z.ZodOptional<z.ZodString>;
|
|
4
|
+
archived: z.ZodOptional<z.ZodBoolean>;
|
|
5
|
+
promotable: z.ZodOptional<z.ZodBoolean>;
|
|
6
|
+
description: z.ZodString;
|
|
7
|
+
}, z.core.$strict>>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAttributeZodSchema = getAttributeZodSchema;
|
|
4
|
+
var zod_1 = require("zod");
|
|
5
|
+
var schema_1 = require("./schema");
|
|
6
|
+
function getAttributeZodSchema() {
|
|
7
|
+
return schema_1.attributePropertyZodSchema
|
|
8
|
+
.and(zod_1.z
|
|
9
|
+
.object({
|
|
10
|
+
key: zod_1.z.string().optional(),
|
|
11
|
+
archived: zod_1.z.boolean().optional(),
|
|
12
|
+
promotable: zod_1.z.boolean().optional(),
|
|
13
|
+
description: zod_1.z.string({
|
|
14
|
+
error: function (issue) { return (issue.input === undefined ? "Required" : undefined); },
|
|
15
|
+
}),
|
|
16
|
+
})
|
|
17
|
+
.strict())
|
|
18
|
+
.superRefine(function (data, ctx) {
|
|
19
|
+
if (!data.type && !data.oneOf) {
|
|
20
|
+
ctx.addIssue({
|
|
21
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
22
|
+
message: "Attribute must define either `type` or `oneOf`.",
|
|
23
|
+
path: ["type"],
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
if (data.type && data.oneOf) {
|
|
27
|
+
ctx.addIssue({
|
|
28
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
29
|
+
message: "Attribute cannot define both `type` and `oneOf`.",
|
|
30
|
+
path: ["oneOf"],
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
(0, schema_1.refineSchemaSemantics)(data, ctx);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=attributeSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attributeSchema.js","sourceRoot":"","sources":["../../src/linter/attributeSchema.ts"],"names":[],"mappings":";;AAIA,sDAiCC;AArCD,2BAAwB;AAExB,mCAA6E;AAE7E,SAAgB,qBAAqB;IACnC,OAAO,mCAA0B;SAC9B,GAAG,CACF,OAAC;SACE,MAAM,CAAC;QACN,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC1B,QAAQ,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;QAChC,UAAU,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;QAClC,WAAW,EAAE,OAAC,CAAC,MAAM,CAAC;YACpB,KAAK,EAAE,UAAC,KAAK,IAAK,OAAA,CAAC,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,EAApD,CAAoD;SACvE,CAAC;KACH,CAAC;SACD,MAAM,EAAE,CACZ;SACA,WAAW,CAAC,UAAC,IAAS,EAAE,GAAG;QAC1B,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YAC9B,GAAG,CAAC,QAAQ,CAAC;gBACX,IAAI,EAAE,OAAC,CAAC,YAAY,CAAC,MAAM;gBAC3B,OAAO,EAAE,iDAAqD;gBAC9D,IAAI,EAAE,CAAC,MAAM,CAAC;aACf,CAAC,CAAC;QACL,CAAC;QAED,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC5B,GAAG,CAAC,QAAQ,CAAC;gBACX,IAAI,EAAE,OAAC,CAAC,YAAY,CAAC,MAAM;gBAC3B,OAAO,EAAE,kDAAsD;gBAC/D,IAAI,EAAE,CAAC,OAAO,CAAC;aAChB,CAAC,CAAC;QACL,CAAC;QAED,IAAA,8BAAqB,EAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Locale } from "@messagevisor/types";
|
|
2
|
+
export type LocaleInheritanceField = "inheritFormatsFrom" | "inheritTranslationsFrom" | "mergeExamplesFrom";
|
|
3
|
+
export interface LocaleCircularDependency {
|
|
4
|
+
field: LocaleInheritanceField;
|
|
5
|
+
cycle: string[];
|
|
6
|
+
}
|
|
7
|
+
export declare function checkLocaleCircularDependency(localesByKey: Record<string, Locale>, field: LocaleInheritanceField): LocaleCircularDependency[];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.checkLocaleCircularDependency = checkLocaleCircularDependency;
|
|
13
|
+
function checkLocaleCircularDependency(localesByKey, field) {
|
|
14
|
+
var cycles = [];
|
|
15
|
+
var reportedCycles = new Set();
|
|
16
|
+
for (var _i = 0, _a = Object.keys(localesByKey); _i < _a.length; _i++) {
|
|
17
|
+
var localeKey = _a[_i];
|
|
18
|
+
var path = [];
|
|
19
|
+
var seenInPath = new Map();
|
|
20
|
+
var currentKey = localeKey;
|
|
21
|
+
while (currentKey) {
|
|
22
|
+
if (seenInPath.has(currentKey)) {
|
|
23
|
+
var cycle = __spreadArray(__spreadArray([], path.slice(seenInPath.get(currentKey)), true), [currentKey], false);
|
|
24
|
+
var normalizedKey = cycle.slice(0, -1).sort().join(">");
|
|
25
|
+
if (!reportedCycles.has(normalizedKey)) {
|
|
26
|
+
reportedCycles.add(normalizedKey);
|
|
27
|
+
cycles.push({ field: field, cycle: cycle });
|
|
28
|
+
}
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
var locale = localesByKey[currentKey];
|
|
32
|
+
if (!locale) {
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
seenInPath.set(currentKey, path.length);
|
|
36
|
+
path.push(currentKey);
|
|
37
|
+
currentKey = locale[field];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return cycles;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=checkLocaleCircularDependency.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkLocaleCircularDependency.js","sourceRoot":"","sources":["../../src/linter/checkLocaleCircularDependency.ts"],"names":[],"mappings":";;;;;;;;;;;AAYA,sEAsCC;AAtCD,SAAgB,6BAA6B,CAC3C,YAAoC,EACpC,KAA6B;IAE7B,IAAM,MAAM,GAA+B,EAAE,CAAC;IAC9C,IAAM,cAAc,GAAG,IAAI,GAAG,EAAU,CAAC;IAEzC,KAAwB,UAAyB,EAAzB,KAAA,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,EAAzB,cAAyB,EAAzB,IAAyB,EAAE,CAAC;QAA/C,IAAM,SAAS,SAAA;QAClB,IAAM,IAAI,GAAa,EAAE,CAAC;QAC1B,IAAM,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;QAC7C,IAAI,UAAU,GAAuB,SAAS,CAAC;QAE/C,OAAO,UAAU,EAAE,CAAC;YAClB,IAAI,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;gBAC/B,IAAM,KAAK,mCAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,UAAE,UAAU,SAAC,CAAC;gBACtE,IAAM,aAAa,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAE1D,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC;oBACvC,cAAc,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;oBAClC,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,OAAA,EAAE,KAAK,OAAA,EAAE,CAAC,CAAC;gBAChC,CAAC;gBAED,MAAM;YACR,CAAC;YAED,IAAM,MAAM,GAAG,YAAY,CAAC,UAAU,CAAC,CAAC;YAExC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,MAAM;YACR,CAAC;YAED,UAAU,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YACxC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YACtB,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Attribute } from "@messagevisor/types";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export declare function getConditionsZodSchema(attributesByKey: Record<string, Attribute>): z.ZodUnion<readonly [z.ZodLiteral<"*">, z.ZodType<any, unknown, z.core.$ZodTypeInternals<any, unknown>>, z.ZodArray<z.ZodType<any, unknown, z.core.$ZodTypeInternals<any, unknown>>>]>;
|