@cms0/cms0 0.0.6 → 0.0.8
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/cjs/libs/cli/build.cjs +1 -2
- package/dist/cjs/libs/cli/descriptor-writer.cjs +19 -3
- package/dist/cjs/libs/cli/paths.cjs +31 -4
- package/dist/esm/libs/cli/build.js +2 -3
- package/dist/esm/libs/cli/descriptor-writer.js +19 -3
- package/dist/esm/libs/cli/paths.js +30 -3
- package/dist/types/libs/cli/build.d.ts.map +1 -1
- package/dist/types/libs/cli/descriptor-writer.d.ts +2 -2
- package/dist/types/libs/cli/descriptor-writer.d.ts.map +1 -1
- package/dist/types/libs/cli/paths.d.ts +6 -2
- package/dist/types/libs/cli/paths.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -3,12 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.buildOnce = buildOnce;
|
|
4
4
|
// Single-shot build that compiles the descriptor, writes it, and publishes it.
|
|
5
5
|
const descriptor_builder_alt_js_1 = require("./descriptor-builder-alt.cjs");
|
|
6
|
-
const paths_js_1 = require("./paths.cjs");
|
|
7
6
|
const publisher_js_1 = require("./publisher.cjs");
|
|
8
7
|
const descriptor_writer_js_1 = require("./descriptor-writer.cjs");
|
|
9
8
|
function buildOnce(resolved) {
|
|
10
9
|
const descriptor = (0, descriptor_builder_alt_js_1.buildDescriptorAlt)(resolved);
|
|
11
|
-
(0, descriptor_writer_js_1.
|
|
10
|
+
(0, descriptor_writer_js_1.writeDescriptorFiles)(descriptor);
|
|
12
11
|
(0, publisher_js_1.publishDescriptor)(resolved, descriptor);
|
|
13
12
|
return descriptor;
|
|
14
13
|
}
|
|
@@ -3,11 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.writeDescriptorFiles = writeDescriptorFiles;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const paths_js_1 = require("./paths.cjs");
|
|
10
|
+
function safeWrite(outputPath, output) {
|
|
11
11
|
try {
|
|
12
12
|
fs_1.default.mkdirSync(path_1.default.dirname(outputPath), { recursive: true });
|
|
13
13
|
fs_1.default.writeFileSync(outputPath, output, "utf8");
|
|
@@ -21,3 +21,19 @@ function writeDescriptorFile(descriptor, outputPath) {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
+
function createSourceTsOutput(descriptor) {
|
|
25
|
+
return `// Auto-generated schema descriptor\nexport const schemaDescriptor = ${JSON.stringify(descriptor, null, 2)} as const;\n`;
|
|
26
|
+
}
|
|
27
|
+
function createEsmOutput(descriptor) {
|
|
28
|
+
return `// Auto-generated schema descriptor\nexport const schemaDescriptor = ${JSON.stringify(descriptor, null, 2)};\n`;
|
|
29
|
+
}
|
|
30
|
+
function createCjsOutput(descriptor) {
|
|
31
|
+
return `// Auto-generated schema descriptor\nexports.schemaDescriptor = ${JSON.stringify(descriptor, null, 2)};\n`;
|
|
32
|
+
}
|
|
33
|
+
function writeDescriptorFiles(descriptor) {
|
|
34
|
+
if (fs_1.default.existsSync(path_1.default.resolve(path_1.default.dirname(paths_js_1.descriptorOutputPaths.sourceTs), ".."))) {
|
|
35
|
+
safeWrite(paths_js_1.descriptorOutputPaths.sourceTs, createSourceTsOutput(descriptor));
|
|
36
|
+
}
|
|
37
|
+
safeWrite(paths_js_1.descriptorOutputPaths.esmJs, createEsmOutput(descriptor));
|
|
38
|
+
safeWrite(paths_js_1.descriptorOutputPaths.cjsJs, createCjsOutput(descriptor));
|
|
39
|
+
}
|
|
@@ -3,9 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.packageRoot = exports.
|
|
6
|
+
exports.packageRoot = exports.descriptorOutputPaths = void 0;
|
|
7
7
|
// Path utilities for locating package-relative outputs.
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
10
|
const url_1 = require("url");
|
|
10
11
|
const importMetaUrl = (() => {
|
|
11
12
|
try {
|
|
@@ -22,7 +23,33 @@ const here = typeof __dirname === "string"
|
|
|
22
23
|
: importMetaUrl
|
|
23
24
|
? path_1.default.dirname((0, url_1.fileURLToPath)(importMetaUrl))
|
|
24
25
|
: process.cwd();
|
|
25
|
-
|
|
26
|
+
function findPackageRoot(startDir) {
|
|
27
|
+
let current = startDir;
|
|
28
|
+
while (true) {
|
|
29
|
+
const pkgPath = path_1.default.join(current, "package.json");
|
|
30
|
+
if (node_fs_1.default.existsSync(pkgPath)) {
|
|
31
|
+
try {
|
|
32
|
+
const pkg = JSON.parse(node_fs_1.default.readFileSync(pkgPath, "utf8"));
|
|
33
|
+
if (pkg.name === "@cms0/cms0") {
|
|
34
|
+
return current;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
// Keep walking up if package.json cannot be parsed.
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const parent = path_1.default.dirname(current);
|
|
42
|
+
if (parent === current)
|
|
43
|
+
break;
|
|
44
|
+
current = parent;
|
|
45
|
+
}
|
|
46
|
+
return path_1.default.resolve(startDir, "../../..");
|
|
47
|
+
}
|
|
48
|
+
const packageRoot = findPackageRoot(here);
|
|
26
49
|
exports.packageRoot = packageRoot;
|
|
27
|
-
const
|
|
28
|
-
|
|
50
|
+
const descriptorOutputPaths = {
|
|
51
|
+
sourceTs: path_1.default.resolve(packageRoot, "src/generated/schema-descriptor.ts"),
|
|
52
|
+
esmJs: path_1.default.resolve(packageRoot, "dist/esm/generated/schema-descriptor.js"),
|
|
53
|
+
cjsJs: path_1.default.resolve(packageRoot, "dist/cjs/generated/schema-descriptor.cjs"),
|
|
54
|
+
};
|
|
55
|
+
exports.descriptorOutputPaths = descriptorOutputPaths;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
// Single-shot build that compiles the descriptor, writes it, and publishes it.
|
|
2
2
|
import { buildDescriptorAlt as buildDescriptor } from "./descriptor-builder-alt.js";
|
|
3
|
-
import { descriptorOutPath } from "./paths.js";
|
|
4
3
|
import { publishDescriptor } from "./publisher.js";
|
|
5
|
-
import {
|
|
4
|
+
import { writeDescriptorFiles } from "./descriptor-writer.js";
|
|
6
5
|
function buildOnce(resolved) {
|
|
7
6
|
const descriptor = buildDescriptor(resolved);
|
|
8
|
-
|
|
7
|
+
writeDescriptorFiles(descriptor);
|
|
9
8
|
publishDescriptor(resolved, descriptor);
|
|
10
9
|
return descriptor;
|
|
11
10
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import { descriptorOutputPaths } from "./paths.js";
|
|
4
|
+
function safeWrite(outputPath, output) {
|
|
5
5
|
try {
|
|
6
6
|
fs.mkdirSync(path.dirname(outputPath), { recursive: true });
|
|
7
7
|
fs.writeFileSync(outputPath, output, "utf8");
|
|
@@ -15,4 +15,20 @@ function writeDescriptorFile(descriptor, outputPath) {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
function createSourceTsOutput(descriptor) {
|
|
19
|
+
return `// Auto-generated schema descriptor\nexport const schemaDescriptor = ${JSON.stringify(descriptor, null, 2)} as const;\n`;
|
|
20
|
+
}
|
|
21
|
+
function createEsmOutput(descriptor) {
|
|
22
|
+
return `// Auto-generated schema descriptor\nexport const schemaDescriptor = ${JSON.stringify(descriptor, null, 2)};\n`;
|
|
23
|
+
}
|
|
24
|
+
function createCjsOutput(descriptor) {
|
|
25
|
+
return `// Auto-generated schema descriptor\nexports.schemaDescriptor = ${JSON.stringify(descriptor, null, 2)};\n`;
|
|
26
|
+
}
|
|
27
|
+
function writeDescriptorFiles(descriptor) {
|
|
28
|
+
if (fs.existsSync(path.resolve(path.dirname(descriptorOutputPaths.sourceTs), ".."))) {
|
|
29
|
+
safeWrite(descriptorOutputPaths.sourceTs, createSourceTsOutput(descriptor));
|
|
30
|
+
}
|
|
31
|
+
safeWrite(descriptorOutputPaths.esmJs, createEsmOutput(descriptor));
|
|
32
|
+
safeWrite(descriptorOutputPaths.cjsJs, createCjsOutput(descriptor));
|
|
33
|
+
}
|
|
34
|
+
export { writeDescriptorFiles };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Path utilities for locating package-relative outputs.
|
|
2
2
|
import path from "path";
|
|
3
|
+
import fs from "node:fs";
|
|
3
4
|
import { fileURLToPath } from "url";
|
|
4
5
|
const importMetaUrl = (() => {
|
|
5
6
|
try {
|
|
@@ -16,6 +17,32 @@ const here = typeof __dirname === "string"
|
|
|
16
17
|
: importMetaUrl
|
|
17
18
|
? path.dirname(fileURLToPath(importMetaUrl))
|
|
18
19
|
: process.cwd();
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
function findPackageRoot(startDir) {
|
|
21
|
+
let current = startDir;
|
|
22
|
+
while (true) {
|
|
23
|
+
const pkgPath = path.join(current, "package.json");
|
|
24
|
+
if (fs.existsSync(pkgPath)) {
|
|
25
|
+
try {
|
|
26
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
27
|
+
if (pkg.name === "@cms0/cms0") {
|
|
28
|
+
return current;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// Keep walking up if package.json cannot be parsed.
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const parent = path.dirname(current);
|
|
36
|
+
if (parent === current)
|
|
37
|
+
break;
|
|
38
|
+
current = parent;
|
|
39
|
+
}
|
|
40
|
+
return path.resolve(startDir, "../../..");
|
|
41
|
+
}
|
|
42
|
+
const packageRoot = findPackageRoot(here);
|
|
43
|
+
const descriptorOutputPaths = {
|
|
44
|
+
sourceTs: path.resolve(packageRoot, "src/generated/schema-descriptor.ts"),
|
|
45
|
+
esmJs: path.resolve(packageRoot, "dist/esm/generated/schema-descriptor.js"),
|
|
46
|
+
cjsJs: path.resolve(packageRoot, "dist/cjs/generated/schema-descriptor.cjs"),
|
|
47
|
+
};
|
|
48
|
+
export { descriptorOutputPaths, packageRoot };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../../src/libs/cli/build.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../../src/libs/cli/build.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,iBAAS,SAAS,CAAC,QAAQ,EAAE,cAAc,GAAG,cAAc,CAK3D;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { FullDescriptor } from "@cms0/shared";
|
|
2
|
-
declare function
|
|
3
|
-
export {
|
|
2
|
+
declare function writeDescriptorFiles(descriptor: FullDescriptor): void;
|
|
3
|
+
export { writeDescriptorFiles };
|
|
4
4
|
//# sourceMappingURL=descriptor-writer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"descriptor-writer.d.ts","sourceRoot":"","sources":["../../../../src/libs/cli/descriptor-writer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"descriptor-writer.d.ts","sourceRoot":"","sources":["../../../../src/libs/cli/descriptor-writer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AA4C9C,iBAAS,oBAAoB,CAAC,UAAU,EAAE,cAAc,QAMvD;AAED,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
declare const packageRoot: string;
|
|
2
|
-
declare const
|
|
3
|
-
|
|
2
|
+
declare const descriptorOutputPaths: {
|
|
3
|
+
sourceTs: string;
|
|
4
|
+
esmJs: string;
|
|
5
|
+
cjsJs: string;
|
|
6
|
+
};
|
|
7
|
+
export { descriptorOutputPaths, packageRoot };
|
|
4
8
|
//# sourceMappingURL=paths.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../../../src/libs/cli/paths.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../../../src/libs/cli/paths.ts"],"names":[],"mappings":"AA+CA,QAAA,MAAM,WAAW,QAAwB,CAAC;AAE1C,QAAA,MAAM,qBAAqB;;;;CAO1B,CAAC;AAEF,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cms0/cms0",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "restricted"
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"ts-node": "^10.9.2",
|
|
58
58
|
"typescript": "^5.9.3",
|
|
59
59
|
"zod": "^4.1.12",
|
|
60
|
-
"@cms0/shared": "0.0.
|
|
60
|
+
"@cms0/shared": "0.0.4"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@types/lodash": "^4.17.21",
|