@proteinjs/reflection-build 1.5.0 → 2.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.
Files changed (80) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/src/BuildContract.d.ts +69 -0
  3. package/dist/src/BuildContract.js +393 -0
  4. package/dist/src/BuildContract.js.map +1 -0
  5. package/dist/src/ReflectionDoctor.d.ts +95 -0
  6. package/dist/src/ReflectionDoctor.js +588 -0
  7. package/dist/src/ReflectionDoctor.js.map +1 -0
  8. package/dist/src/build.d.ts +5 -1
  9. package/dist/src/build.js +13 -77
  10. package/dist/src/build.js.map +1 -1
  11. package/dist/src/codegen/writeGeneratedIndex.d.ts +18 -0
  12. package/dist/src/codegen/writeGeneratedIndex.js +58 -15
  13. package/dist/src/codegen/writeGeneratedIndex.js.map +1 -1
  14. package/dist/src/parser/createGraphBuilder.js +30 -5
  15. package/dist/src/parser/createGraphBuilder.js.map +1 -1
  16. package/dist/src/runBuild.js +12 -2
  17. package/dist/src/runBuild.js.map +1 -1
  18. package/dist/src/runDoctor.d.ts +2 -0
  19. package/dist/src/runDoctor.js +83 -0
  20. package/dist/src/runDoctor.js.map +1 -0
  21. package/dist/test/GraphEmitRelativePaths.test.d.ts +1 -0
  22. package/dist/test/GraphEmitRelativePaths.test.js +162 -0
  23. package/dist/test/GraphEmitRelativePaths.test.js.map +1 -0
  24. package/dist/test/ReflectionDoctor.test.d.ts +1 -0
  25. package/dist/test/ReflectionDoctor.test.js +316 -0
  26. package/dist/test/ReflectionDoctor.test.js.map +1 -0
  27. package/dist/test/TestSubpathContract.test.d.ts +1 -0
  28. package/dist/test/TestSubpathContract.test.js +260 -0
  29. package/dist/test/TestSubpathContract.test.js.map +1 -0
  30. package/dist/test/ValidateDontMutate.test.d.ts +1 -0
  31. package/dist/test/ValidateDontMutate.test.js +238 -0
  32. package/dist/test/ValidateDontMutate.test.js.map +1 -0
  33. package/dist/test/examples/source-repository/a/generated/index.js +1 -1
  34. package/dist/test/examples/source-repository/a/generated/index.js.map +1 -1
  35. package/dist/test/examples/source-repository/b/generated/index.js +1 -1
  36. package/dist/test/examples/source-repository/b/generated/index.js.map +1 -1
  37. package/package.json +5 -4
  38. package/src/BuildContract.ts +384 -0
  39. package/src/ReflectionDoctor.ts +589 -0
  40. package/src/build.ts +19 -56
  41. package/src/codegen/writeGeneratedIndex.ts +51 -13
  42. package/src/parser/createGraphBuilder.ts +9 -4
  43. package/src/runBuild.ts +7 -1
  44. package/src/runDoctor.ts +34 -0
  45. package/test/GraphEmitRelativePaths.test.ts +95 -0
  46. package/test/ReflectionDoctor.test.ts +193 -0
  47. package/test/TestSubpathContract.test.ts +148 -0
  48. package/test/ValidateDontMutate.test.ts +126 -0
  49. package/test/examples/source-repository/a/dist/BuildContract.d.ts +69 -0
  50. package/test/examples/source-repository/a/dist/BuildContract.js +393 -0
  51. package/test/examples/source-repository/a/dist/BuildContract.js.map +1 -0
  52. package/test/examples/source-repository/a/dist/build.d.ts +5 -1
  53. package/test/examples/source-repository/a/dist/build.js +13 -77
  54. package/test/examples/source-repository/a/dist/build.js.map +1 -1
  55. package/test/examples/source-repository/a/dist/codegen/writeGeneratedIndex.d.ts +18 -0
  56. package/test/examples/source-repository/a/dist/codegen/writeGeneratedIndex.js +58 -15
  57. package/test/examples/source-repository/a/dist/codegen/writeGeneratedIndex.js.map +1 -1
  58. package/test/examples/source-repository/a/dist/generated/index.js +1 -1
  59. package/test/examples/source-repository/a/dist/generated/index.js.map +1 -1
  60. package/test/examples/source-repository/a/dist/parser/createGraphBuilder.js +30 -5
  61. package/test/examples/source-repository/a/dist/parser/createGraphBuilder.js.map +1 -1
  62. package/test/examples/source-repository/a/dist/runBuild.js +12 -2
  63. package/test/examples/source-repository/a/dist/runBuild.js.map +1 -1
  64. package/test/examples/source-repository/a/generated/index.ts +1 -1
  65. package/test/examples/source-repository/b/dist/BuildContract.d.ts +69 -0
  66. package/test/examples/source-repository/b/dist/BuildContract.js +393 -0
  67. package/test/examples/source-repository/b/dist/BuildContract.js.map +1 -0
  68. package/test/examples/source-repository/b/dist/build.d.ts +5 -1
  69. package/test/examples/source-repository/b/dist/build.js +13 -77
  70. package/test/examples/source-repository/b/dist/build.js.map +1 -1
  71. package/test/examples/source-repository/b/dist/codegen/writeGeneratedIndex.d.ts +18 -0
  72. package/test/examples/source-repository/b/dist/codegen/writeGeneratedIndex.js +58 -15
  73. package/test/examples/source-repository/b/dist/codegen/writeGeneratedIndex.js.map +1 -1
  74. package/test/examples/source-repository/b/dist/generated/index.js +1 -1
  75. package/test/examples/source-repository/b/dist/generated/index.js.map +1 -1
  76. package/test/examples/source-repository/b/dist/parser/createGraphBuilder.js +30 -5
  77. package/test/examples/source-repository/b/dist/parser/createGraphBuilder.js.map +1 -1
  78. package/test/examples/source-repository/b/dist/runBuild.js +12 -2
  79. package/test/examples/source-repository/b/dist/runBuild.js.map +1 -1
  80. package/test/examples/source-repository/b/generated/index.ts +1 -1
@@ -0,0 +1,126 @@
1
+ import * as fs from 'fs';
2
+ import * as os from 'os';
3
+ import * as path from 'path';
4
+ import { build } from '../src/build';
5
+
6
+ /**
7
+ * Validate-don't-mutate (task #104 §3.3): the build computes the package-config contract and
8
+ * VALIDATES it instead of silently rewriting files.
9
+ *
10
+ * The founder's UX bar:
11
+ * - ABSENCE is not a mismatch — a fresh package missing main/types gets them SET (today's
12
+ * behavior kept; the copy-a-package workflow survives).
13
+ * - The build errors ONLY on conflicting existing values, and the error is friendly: plain
14
+ * words, why it matters, the exact lines to paste, `--fix` offered first.
15
+ * - `reflection-build --fix` writes the contract; a second run is a no-op.
16
+ *
17
+ * Red-before-green: against pre-change code the conflict tests fail because the mutating
18
+ * build succeeds and silently rewrites package.json.
19
+ */
20
+ describe("validate-don't-mutate", () => {
21
+ let pkgDir: string;
22
+ const savedEnv: { [key: string]: string | undefined } = {};
23
+
24
+ const writeFixture = (packageJson: any) => {
25
+ pkgDir = fs.mkdtempSync(path.join(os.tmpdir(), 'refl-validate-'));
26
+ fs.writeFileSync(path.join(pkgDir, 'package.json'), JSON.stringify(packageJson, null, 2));
27
+ fs.mkdirSync(path.join(pkgDir, 'src'));
28
+ fs.writeFileSync(path.join(pkgDir, 'src', 'index.ts'), `export * from './Example';\n`);
29
+ fs.writeFileSync(path.join(pkgDir, 'src', 'Example.ts'), `export class Example {}\n`);
30
+ process.env.INIT_CWD = pkgDir;
31
+ };
32
+
33
+ const readPackageJson = () => JSON.parse(fs.readFileSync(path.join(pkgDir, 'package.json'), 'utf-8'));
34
+
35
+ beforeEach(() => {
36
+ for (const key of ['INIT_CWD', 'REFLECTION_SOURCE_DIRS', 'REFLECTION_EXPORT_FROM', 'REFLECTION_DIST_DIR']) {
37
+ savedEnv[key] = process.env[key];
38
+ delete process.env[key];
39
+ }
40
+ });
41
+
42
+ afterEach(() => {
43
+ for (const key of Object.keys(savedEnv)) {
44
+ if (typeof savedEnv[key] === 'undefined') {
45
+ delete process.env[key];
46
+ } else {
47
+ process.env[key] = savedEnv[key];
48
+ }
49
+ }
50
+ fs.rmdirSync(pkgDir, { recursive: true });
51
+ });
52
+
53
+ it('fails the build on a conflicting main and leaves package.json untouched', async () => {
54
+ writeFixture({ name: '@test/validate-fixture', version: '1.0.0', main: './dist/custom-entry.js' });
55
+ // The conflicting value points at a REAL file — a deliberate setting, not boilerplate.
56
+ fs.mkdirSync(path.join(pkgDir, 'dist'));
57
+ fs.writeFileSync(path.join(pkgDir, 'dist', 'custom-entry.js'), 'module.exports = {};\n');
58
+ const before = fs.readFileSync(path.join(pkgDir, 'package.json'), 'utf-8');
59
+
60
+ await expect(build()).rejects.toThrow(/--fix/);
61
+ expect(fs.readFileSync(path.join(pkgDir, 'package.json'), 'utf-8')).toBe(before);
62
+ });
63
+
64
+ it('the conflict error is friendly: offers --fix first, then the exact lines to paste', async () => {
65
+ writeFixture({ name: '@test/validate-fixture', version: '1.0.0', main: './dist/custom-entry.js' });
66
+ fs.mkdirSync(path.join(pkgDir, 'dist'));
67
+ fs.writeFileSync(path.join(pkgDir, 'dist', 'custom-entry.js'), 'module.exports = {};\n');
68
+
69
+ let message = '';
70
+ try {
71
+ await build();
72
+ } catch (error: any) {
73
+ message = error.message;
74
+ }
75
+ expect(message).toContain('reflection-build --fix');
76
+ expect(message).toContain('"main": "./dist/generated/index.js"');
77
+ expect(message).toContain('"types": "./dist/generated/index.d.ts"');
78
+ // --fix is the first remedy offered, before the paste-able lines.
79
+ expect(message.indexOf('--fix')).toBeGreaterThan(-1);
80
+ expect(message.indexOf('--fix')).toBeLessThan(message.indexOf('"main": "./dist/generated/index.js"'));
81
+ // Plain words about why it matters, not just a diff.
82
+ expect(message.toLowerCase()).toContain('consumer');
83
+ });
84
+
85
+ it('sets absent main/types silently — the fresh/copied-package workflow survives', async () => {
86
+ writeFixture({ name: '@test/validate-fixture', version: '1.0.0' });
87
+ await build();
88
+ const packageJson = readPackageJson();
89
+ expect(packageJson.main).toBe('./dist/generated/index.js');
90
+ expect(packageJson.types).toBe('./dist/generated/index.d.ts');
91
+ });
92
+
93
+ it('treats npm-init boilerplate (main pointing at a file that does not exist) as absence', async () => {
94
+ writeFixture({ name: '@test/validate-fixture', version: '1.0.0', main: 'index.js' });
95
+ await build();
96
+ expect(readPackageJson().main).toBe('./dist/generated/index.js');
97
+ });
98
+
99
+ it('accepts a package already on contract without touching it', async () => {
100
+ writeFixture({
101
+ name: '@test/validate-fixture',
102
+ version: '1.0.0',
103
+ main: './dist/generated/index.js',
104
+ types: './dist/generated/index.d.ts',
105
+ });
106
+ await build();
107
+ const first = fs.readFileSync(path.join(pkgDir, 'package.json'), 'utf-8');
108
+ await build();
109
+ expect(fs.readFileSync(path.join(pkgDir, 'package.json'), 'utf-8')).toBe(first);
110
+ });
111
+
112
+ it('--fix rewrites conflicting values to the contract; a second run is a no-op', async () => {
113
+ writeFixture({ name: '@test/validate-fixture', version: '1.0.0', main: './dist/custom-entry.js' });
114
+ fs.mkdirSync(path.join(pkgDir, 'dist'));
115
+ fs.writeFileSync(path.join(pkgDir, 'dist', 'custom-entry.js'), 'module.exports = {};\n');
116
+
117
+ await build({ fix: true });
118
+ const packageJson = readPackageJson();
119
+ expect(packageJson.main).toBe('./dist/generated/index.js');
120
+ expect(packageJson.types).toBe('./dist/generated/index.d.ts');
121
+
122
+ const afterFix = fs.readFileSync(path.join(pkgDir, 'package.json'), 'utf-8');
123
+ await build();
124
+ expect(fs.readFileSync(path.join(pkgDir, 'package.json'), 'utf-8')).toBe(afterFix);
125
+ });
126
+ });
@@ -0,0 +1,69 @@
1
+ export interface BuildContractOptions {
2
+ /** Root of the package being built (contains package.json) */
3
+ packageDir: string;
4
+ /** First REFLECTION_SOURCE_DIRS entry; 'src' for prod builds */
5
+ primaryRoot: string;
6
+ /** REFLECTION_DIST_DIR or 'dist' */
7
+ distDirRel: string;
8
+ /** Absolute path to the generated index .ts this invocation emits */
9
+ generatedIndexPath: string;
10
+ /** Write conflicting values to the contract instead of failing the build */
11
+ fix: boolean;
12
+ }
13
+ /**
14
+ * The package-config contract of a reflection build (task #104 §3.3, validate-don't-mutate).
15
+ *
16
+ * A build's artifact is only usable if the package's config points at it, so reflection-build
17
+ * owns that config as a contract instead of silently rewriting files on every build:
18
+ *
19
+ * - ABSENT config is completed in place (a fresh or copied package gets main/types, subpath
20
+ * mappings, stubs — the zero-ceremony workflow survives).
21
+ * - EXISTING config that conflicts with the contract fails the build with a friendly error
22
+ * (plain words, why it matters, the exact lines to paste, `--fix` offered first) and leaves
23
+ * every file untouched.
24
+ * - `reflection-build --fix` writes the contract over conflicting values; it is idempotent.
25
+ *
26
+ * Prod builds (primary root 'src') own main/types + the tsconfig include. Subpath builds
27
+ * (primary root e.g. 'test') own the complete subpath contract — root <root>.js/<root>.d.ts
28
+ * stubs, exports/typesVersions mappings, files[] entries, tsconfig excludes (the d51556f0
29
+ * class, generalized): consumers must resolve the subpath to built dist in every install
30
+ * shape and resolution mode, never to sources.
31
+ */
32
+ export declare class BuildContract {
33
+ private readonly options;
34
+ constructor(options: BuildContractOptions);
35
+ apply(): Promise<void>;
36
+ private applyPackageJson;
37
+ /** Prod builds: main/types point at the built reflection artifact. */
38
+ private settleEntryPoints;
39
+ /** Subpath builds: exports map "." and "./<root>" to the built artifacts. */
40
+ private settleSubpathExports;
41
+ /** Subpath builds: typesVersions carries the subpath's types for node10 resolution. */
42
+ private settleTypesVersions;
43
+ /** Subpath builds: an existing files allowlist must keep shipping the root stubs. */
44
+ private settleFilesAllowlist;
45
+ /**
46
+ * Subpath builds: root stubs that win the node10/paths-mapped file lookup, so every install
47
+ * shape resolves the subpath to built dist — never to sources (the TS6059/ts-jest class).
48
+ */
49
+ private applyStubs;
50
+ /**
51
+ * tsconfig: include the generated index; on subpath builds, exclude the root stubs from
52
+ * compilation. List membership only — nothing here can conflict.
53
+ */
54
+ private applyTsconfig;
55
+ /**
56
+ * Settle one string field: absent → set; equal → ok; a dangling value (points at a file
57
+ * that does not exist — npm init's boilerplate `"main": "index.js"`, a stale copy) → set;
58
+ * a value that points at a real, different file is a deliberate setting → conflict.
59
+ */
60
+ private settleString;
61
+ private formatConflicts;
62
+ private isProd;
63
+ private prodIndexJs;
64
+ private prodIndexDts;
65
+ private subpathIndexJs;
66
+ private subpathIndexDts;
67
+ private stubJsName;
68
+ private stubDtsName;
69
+ }
@@ -0,0 +1,393 @@
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __generator = (this && this.__generator) || function (thisArg, body) {
35
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
36
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
37
+ function verb(n) { return function (v) { return step([n, v]); }; }
38
+ function step(op) {
39
+ if (f) throw new TypeError("Generator is already executing.");
40
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
41
+ 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;
42
+ if (y = 0, t) op = [op[0] & 2, t.value];
43
+ switch (op[0]) {
44
+ case 0: case 1: t = op; break;
45
+ case 4: _.label++; return { value: op[1], done: false };
46
+ case 5: _.label++; y = op[1]; op = [0]; continue;
47
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
48
+ default:
49
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
50
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
51
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
52
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
53
+ if (t[2]) _.ops.pop();
54
+ _.trys.pop(); continue;
55
+ }
56
+ op = body.call(thisArg, _);
57
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
58
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
59
+ }
60
+ };
61
+ Object.defineProperty(exports, "__esModule", { value: true });
62
+ exports.BuildContract = void 0;
63
+ var fs = __importStar(require("fs"));
64
+ var path = __importStar(require("path"));
65
+ var tsconfigTemplate = require('./tsconfigTemplate.json');
66
+ /**
67
+ * The package-config contract of a reflection build (task #104 §3.3, validate-don't-mutate).
68
+ *
69
+ * A build's artifact is only usable if the package's config points at it, so reflection-build
70
+ * owns that config as a contract instead of silently rewriting files on every build:
71
+ *
72
+ * - ABSENT config is completed in place (a fresh or copied package gets main/types, subpath
73
+ * mappings, stubs — the zero-ceremony workflow survives).
74
+ * - EXISTING config that conflicts with the contract fails the build with a friendly error
75
+ * (plain words, why it matters, the exact lines to paste, `--fix` offered first) and leaves
76
+ * every file untouched.
77
+ * - `reflection-build --fix` writes the contract over conflicting values; it is idempotent.
78
+ *
79
+ * Prod builds (primary root 'src') own main/types + the tsconfig include. Subpath builds
80
+ * (primary root e.g. 'test') own the complete subpath contract — root <root>.js/<root>.d.ts
81
+ * stubs, exports/typesVersions mappings, files[] entries, tsconfig excludes (the d51556f0
82
+ * class, generalized): consumers must resolve the subpath to built dist in every install
83
+ * shape and resolution mode, never to sources.
84
+ */
85
+ var BuildContract = /** @class */ (function () {
86
+ function BuildContract(options) {
87
+ this.options = options;
88
+ }
89
+ BuildContract.prototype.apply = function () {
90
+ return __awaiter(this, void 0, void 0, function () {
91
+ var conflicts, writes, _i, writes_1, write;
92
+ return __generator(this, function (_a) {
93
+ conflicts = [];
94
+ writes = [];
95
+ this.applyPackageJson(conflicts, writes);
96
+ this.applyStubs(conflicts, writes);
97
+ this.applyTsconfig(writes);
98
+ if (conflicts.length > 0) {
99
+ throw new Error(this.formatConflicts(conflicts));
100
+ }
101
+ for (_i = 0, writes_1 = writes; _i < writes_1.length; _i++) {
102
+ write = writes_1[_i];
103
+ fs.writeFileSync(write.filePath, write.content);
104
+ }
105
+ return [2 /*return*/];
106
+ });
107
+ });
108
+ };
109
+ BuildContract.prototype.applyPackageJson = function (conflicts, writes) {
110
+ var packageJsonPath = path.join(this.options.packageDir, 'package.json');
111
+ if (!fs.existsSync(packageJsonPath)) {
112
+ throw new Error("package.json does not exist, run `npm init -y` to create one");
113
+ }
114
+ var original = fs.readFileSync(packageJsonPath, 'utf-8');
115
+ var packageJson = JSON.parse(original);
116
+ if (this.isProd()) {
117
+ this.settleEntryPoints(packageJson, conflicts);
118
+ }
119
+ else {
120
+ this.settleSubpathExports(packageJson, conflicts);
121
+ this.settleTypesVersions(packageJson, conflicts);
122
+ this.settleFilesAllowlist(packageJson);
123
+ }
124
+ var updated = JSON.stringify(packageJson, null, 2);
125
+ if (updated !== JSON.stringify(JSON.parse(original), null, 2)) {
126
+ writes.push({ filePath: packageJsonPath, content: updated });
127
+ }
128
+ };
129
+ /** Prod builds: main/types point at the built reflection artifact. */
130
+ BuildContract.prototype.settleEntryPoints = function (packageJson, conflicts) {
131
+ var pasteBlock = [" \"main\": \"".concat(this.prodIndexJs(), "\","), " \"types\": \"".concat(this.prodIndexDts(), "\"")].join('\n');
132
+ var whyItMatters = 'Every consumer loads this package through main/types; pointing them anywhere but the ' +
133
+ 'built reflection artifact ships a package that loads the wrong code.';
134
+ this.settleString(packageJson, 'main', this.prodIndexJs(), conflicts, whyItMatters, pasteBlock);
135
+ this.settleString(packageJson, 'types', this.prodIndexDts(), conflicts, whyItMatters, pasteBlock);
136
+ };
137
+ /** Subpath builds: exports map "." and "./<root>" to the built artifacts. */
138
+ BuildContract.prototype.settleSubpathExports = function (packageJson, conflicts) {
139
+ var _a;
140
+ var root = this.options.primaryRoot;
141
+ var expectedExports = (_a = {
142
+ '.': { types: this.prodIndexDts(), default: this.prodIndexJs() }
143
+ },
144
+ _a["./".concat(root)] = { types: this.subpathIndexDts(), default: this.subpathIndexJs() },
145
+ _a);
146
+ var whyItMatters = "Consumers import '<package>/".concat(root, "' through these mappings; a wrong mapping resolves ") +
147
+ 'to the wrong files (or to sources), breaking consumer builds.';
148
+ if (packageJson.exports == null) {
149
+ packageJson.exports = expectedExports;
150
+ return;
151
+ }
152
+ for (var _i = 0, _b = Object.keys(expectedExports); _i < _b.length; _i++) {
153
+ var subpath = _b[_i];
154
+ var expected = expectedExports[subpath];
155
+ var current = packageJson.exports[subpath];
156
+ if (current == null) {
157
+ packageJson.exports[subpath] = expected;
158
+ }
159
+ else if (JSON.stringify(current) !== JSON.stringify(expected)) {
160
+ if (this.options.fix) {
161
+ packageJson.exports[subpath] = expected;
162
+ }
163
+ else {
164
+ conflicts.push({
165
+ file: 'package.json',
166
+ found: "\"exports\" maps \"".concat(subpath, "\" to ").concat(JSON.stringify(current)),
167
+ expected: JSON.stringify(expected),
168
+ whyItMatters: whyItMatters,
169
+ pasteBlock: " \"exports\": ".concat(JSON.stringify(expectedExports, null, 2).replace(/\n/g, '\n ')),
170
+ });
171
+ }
172
+ }
173
+ }
174
+ };
175
+ /** Subpath builds: typesVersions carries the subpath's types for node10 resolution. */
176
+ BuildContract.prototype.settleTypesVersions = function (packageJson, conflicts) {
177
+ var _a;
178
+ var root = this.options.primaryRoot;
179
+ // No leading './' by typesVersions convention.
180
+ var expected = [this.subpathIndexDts().replace(/^\.\//, '')];
181
+ var expectedBlock = { '*': (_a = {}, _a[root] = expected, _a) };
182
+ if (packageJson.typesVersions == null) {
183
+ packageJson.typesVersions = expectedBlock;
184
+ return;
185
+ }
186
+ if (packageJson.typesVersions['*'] == null) {
187
+ packageJson.typesVersions['*'] = expectedBlock['*'];
188
+ return;
189
+ }
190
+ var current = packageJson.typesVersions['*'][root];
191
+ if (current == null) {
192
+ packageJson.typesVersions['*'][root] = expected;
193
+ }
194
+ else if (JSON.stringify(current) !== JSON.stringify(expected)) {
195
+ if (this.options.fix) {
196
+ packageJson.typesVersions['*'][root] = expected;
197
+ }
198
+ else {
199
+ conflicts.push({
200
+ file: 'package.json',
201
+ found: "\"typesVersions\" maps \"".concat(root, "\" to ").concat(JSON.stringify(current)),
202
+ expected: JSON.stringify(expected),
203
+ whyItMatters: "Editors and node10-resolution consumers find '<package>/".concat(root, "' types through this ") +
204
+ 'mapping; a wrong mapping breaks type resolution for every consumer.',
205
+ pasteBlock: " \"typesVersions\": ".concat(JSON.stringify(expectedBlock, null, 2).replace(/\n/g, '\n ')),
206
+ });
207
+ }
208
+ }
209
+ };
210
+ /** Subpath builds: an existing files allowlist must keep shipping the root stubs. */
211
+ BuildContract.prototype.settleFilesAllowlist = function (packageJson) {
212
+ if (!Array.isArray(packageJson.files)) {
213
+ // No allowlist means npm publishes the stubs already; adding one would change what
214
+ // gets published, which is not this contract's call.
215
+ return;
216
+ }
217
+ for (var _i = 0, _a = [this.stubJsName(), this.stubDtsName()]; _i < _a.length; _i++) {
218
+ var stub = _a[_i];
219
+ if (!packageJson.files.includes(stub)) {
220
+ packageJson.files.push(stub);
221
+ }
222
+ }
223
+ };
224
+ /**
225
+ * Subpath builds: root stubs that win the node10/paths-mapped file lookup, so every install
226
+ * shape resolves the subpath to built dist — never to sources (the TS6059/ts-jest class).
227
+ */
228
+ BuildContract.prototype.applyStubs = function (conflicts, writes) {
229
+ if (this.isProd()) {
230
+ return;
231
+ }
232
+ var root = this.options.primaryRoot;
233
+ var targetNoExt = "./".concat(this.options.distDirRel, "/generated/").concat(root, "/index");
234
+ var whyItMatters = "Consumers compiled with node10/classic resolution (or a tsconfig paths mapping) resolve " +
235
+ "'<package>/".concat(root, "' as a file path, bypassing the exports map; without a root stub that ") +
236
+ 'lands on sources in workspace-symlinked installs (TS6059 breaks the consumer build).';
237
+ var stubJs = {
238
+ file: this.stubJsName(),
239
+ content: "// Node10/classic-resolution stub for the `./".concat(root, "` subpath, owned by reflection-build.\n") +
240
+ "// Consumers that bypass the exports map (node10 resolution, tsconfig paths mappings) resolve\n" +
241
+ "// this file path first, so every install shape loads the built dist \u2014 never sources.\n" +
242
+ "module.exports = require('".concat(targetNoExt, ".js');\n"),
243
+ };
244
+ var stubDts = {
245
+ file: this.stubDtsName(),
246
+ content: "// Types counterpart of ".concat(this.stubJsName(), " \u2014 see that file for why this stub exists.\n") +
247
+ "export * from '".concat(targetNoExt, "';\n"),
248
+ };
249
+ for (var _i = 0, _a = [stubJs, stubDts]; _i < _a.length; _i++) {
250
+ var stub = _a[_i];
251
+ var stubPath = path.join(this.options.packageDir, stub.file);
252
+ if (!fs.existsSync(stubPath)) {
253
+ writes.push({ filePath: stubPath, content: stub.content });
254
+ continue;
255
+ }
256
+ var current = fs.readFileSync(stubPath, 'utf-8');
257
+ if (current.includes(targetNoExt)) {
258
+ continue;
259
+ }
260
+ if (this.options.fix) {
261
+ writes.push({ filePath: stubPath, content: stub.content });
262
+ }
263
+ else {
264
+ conflicts.push({
265
+ file: stub.file,
266
+ found: "".concat(stub.file, " exists but does not point at ").concat(targetNoExt),
267
+ expected: targetNoExt,
268
+ whyItMatters: whyItMatters,
269
+ pasteBlock: stub.content.replace(/^/gm, ' ').trimRight(),
270
+ });
271
+ }
272
+ }
273
+ };
274
+ /**
275
+ * tsconfig: include the generated index; on subpath builds, exclude the root stubs from
276
+ * compilation. List membership only — nothing here can conflict.
277
+ */
278
+ BuildContract.prototype.applyTsconfig = function (writes) {
279
+ var tsconfigPath = path.join(this.options.packageDir, 'tsconfig.json');
280
+ var includePath = "./".concat(path.relative(this.options.packageDir, this.options.generatedIndexPath));
281
+ if (!fs.existsSync(tsconfigPath)) {
282
+ var tsconfig_1 = Object.assign({}, tsconfigTemplate);
283
+ tsconfig_1.include = [includePath];
284
+ if (!this.isProd()) {
285
+ // Fresh exclude must carry node_modules: an explicit exclude replaces the default one.
286
+ tsconfig_1.exclude = ['node_modules', this.stubJsName(), this.stubDtsName()];
287
+ }
288
+ writes.push({ filePath: tsconfigPath, content: JSON.stringify(tsconfig_1, null, 4) });
289
+ return;
290
+ }
291
+ var original = fs.readFileSync(tsconfigPath, 'utf-8');
292
+ var tsconfig = JSON.parse(original);
293
+ if (tsconfig.include && !tsconfig.include.includes(includePath)) {
294
+ tsconfig.include.push(includePath);
295
+ }
296
+ if (!this.isProd()) {
297
+ if (!Array.isArray(tsconfig.exclude)) {
298
+ tsconfig.exclude = ['node_modules'];
299
+ }
300
+ for (var _i = 0, _a = [this.stubJsName(), this.stubDtsName()]; _i < _a.length; _i++) {
301
+ var stub = _a[_i];
302
+ if (!tsconfig.exclude.includes(stub)) {
303
+ tsconfig.exclude.push(stub);
304
+ }
305
+ }
306
+ }
307
+ var updated = JSON.stringify(tsconfig, null, 4);
308
+ if (updated !== JSON.stringify(JSON.parse(original), null, 4)) {
309
+ writes.push({ filePath: tsconfigPath, content: updated });
310
+ }
311
+ };
312
+ /**
313
+ * Settle one string field: absent → set; equal → ok; a dangling value (points at a file
314
+ * that does not exist — npm init's boilerplate `"main": "index.js"`, a stale copy) → set;
315
+ * a value that points at a real, different file is a deliberate setting → conflict.
316
+ */
317
+ BuildContract.prototype.settleString = function (packageJson, field, expected, conflicts, whyItMatters, pasteBlock) {
318
+ var current = packageJson[field];
319
+ if (current === expected) {
320
+ return;
321
+ }
322
+ if (typeof current === 'string' && fs.existsSync(path.join(this.options.packageDir, current))) {
323
+ if (this.options.fix) {
324
+ packageJson[field] = expected;
325
+ }
326
+ else {
327
+ conflicts.push({
328
+ file: 'package.json',
329
+ found: "\"".concat(field, "\" is \"").concat(current, "\""),
330
+ expected: expected,
331
+ whyItMatters: whyItMatters,
332
+ pasteBlock: pasteBlock,
333
+ });
334
+ }
335
+ return;
336
+ }
337
+ packageJson[field] = expected;
338
+ };
339
+ BuildContract.prototype.formatConflicts = function (conflicts) {
340
+ var lines = [];
341
+ lines.push("reflection-build: this package's config conflicts with what the build produces.");
342
+ lines.push("Nothing was changed on disk.");
343
+ lines.push('');
344
+ for (var _i = 0, conflicts_1 = conflicts; _i < conflicts_1.length; _i++) {
345
+ var conflict = conflicts_1[_i];
346
+ lines.push("- ".concat(conflict.file, ": ").concat(conflict.found));
347
+ lines.push(" the build's artifact is ".concat(conflict.expected));
348
+ lines.push(" Why it matters: ".concat(conflict.whyItMatters));
349
+ }
350
+ lines.push('');
351
+ lines.push("The quickest fix \u2014 rewrite just these fields to match the build:");
352
+ lines.push('');
353
+ lines.push(" npx reflection-build --fix");
354
+ lines.push('');
355
+ lines.push("Or paste the expected values in yourself:");
356
+ lines.push('');
357
+ var seen = {};
358
+ for (var _a = 0, conflicts_2 = conflicts; _a < conflicts_2.length; _a++) {
359
+ var conflict = conflicts_2[_a];
360
+ if (seen[conflict.pasteBlock]) {
361
+ continue;
362
+ }
363
+ seen[conflict.pasteBlock] = true;
364
+ lines.push(conflict.pasteBlock);
365
+ lines.push('');
366
+ }
367
+ return lines.join('\n');
368
+ };
369
+ BuildContract.prototype.isProd = function () {
370
+ return this.options.primaryRoot === 'src';
371
+ };
372
+ BuildContract.prototype.prodIndexJs = function () {
373
+ return "./".concat(path.join(this.options.distDirRel, 'generated', 'index.js'));
374
+ };
375
+ BuildContract.prototype.prodIndexDts = function () {
376
+ return "./".concat(path.join(this.options.distDirRel, 'generated', 'index.d.ts'));
377
+ };
378
+ BuildContract.prototype.subpathIndexJs = function () {
379
+ return "./".concat(path.join(this.options.distDirRel, 'generated', this.options.primaryRoot, 'index.js'));
380
+ };
381
+ BuildContract.prototype.subpathIndexDts = function () {
382
+ return "./".concat(path.join(this.options.distDirRel, 'generated', this.options.primaryRoot, 'index.d.ts'));
383
+ };
384
+ BuildContract.prototype.stubJsName = function () {
385
+ return "".concat(this.options.primaryRoot, ".js");
386
+ };
387
+ BuildContract.prototype.stubDtsName = function () {
388
+ return "".concat(this.options.primaryRoot, ".d.ts");
389
+ };
390
+ return BuildContract;
391
+ }());
392
+ exports.BuildContract = BuildContract;
393
+ //# sourceMappingURL=BuildContract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BuildContract.js","sourceRoot":"","sources":["../../../../../src/BuildContract.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyB;AACzB,yCAA6B;AAC7B,IAAM,gBAAgB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;AA4B5D;;;;;;;;;;;;;;;;;;GAkBG;AACH;IACE,uBAA6B,OAA6B;QAA7B,YAAO,GAAP,OAAO,CAAsB;IAAG,CAAC;IAExD,6BAAK,GAAX;;;;gBAIQ,SAAS,GAAe,EAAE,CAAC;gBAC3B,MAAM,GAAmB,EAAE,CAAC;gBAClC,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;gBACzC,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;gBACnC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;gBAC3B,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;oBACxB,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC;iBAClD;gBAED,WAA0B,EAAN,iBAAM,EAAN,oBAAM,EAAN,IAAM,EAAE;oBAAjB,KAAK;oBACd,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;iBACjD;;;;KACF;IAEO,wCAAgB,GAAxB,UAAyB,SAAqB,EAAE,MAAsB;QACpE,IAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,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AC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,WAAW,EAAE,YAAY,CAAC,CAAE,CAAC;IAC9E,CAAC;IAEO,sCAAc,GAAtB;QACE,OAAO,YAAK,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,UAAU,CAAC,CAAE,CAAC;IACtG,CAAC;IAEO,uCAAe,GAAvB;QACE,OAAO,YAAK,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,YAAY,CAAC,CAAE,CAAC;IACxG,CAAC;IAEO,kCAAU,GAAlB;QACE,OAAO,UAAG,IAAI,CAAC,OAAO,CAAC,WAAW,QAAK,CAAC;IAC1C,CAAC;IAEO,mCAAW,GAAnB;QACE,OAAO,UAAG,IAAI,CAAC,OAAO,CAAC,WAAW,UAAO,CAAC;IAC5C,CAAC;IACH,oBAAC;AAAD,CAAC,AA9UD,IA8UC;AA9UY,sCAAa"}
@@ -1 +1,5 @@
1
- export declare function build(): Promise<void>;
1
+ export interface BuildOptions {
2
+ /** Write conflicting package config to the contract instead of failing (reflection-build --fix) */
3
+ fix?: boolean;
4
+ }
5
+ export declare function build(options?: BuildOptions): Promise<void>;