@memberjunction/installer 5.38.0 → 5.39.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 (37) hide show
  1. package/dist/InstallerEngine.d.ts +6 -0
  2. package/dist/InstallerEngine.d.ts.map +1 -1
  3. package/dist/InstallerEngine.js +6 -0
  4. package/dist/InstallerEngine.js.map +1 -1
  5. package/dist/adapters/GitHubReleaseProvider.d.ts +5 -35
  6. package/dist/adapters/GitHubReleaseProvider.d.ts.map +1 -1
  7. package/dist/adapters/GitHubReleaseProvider.js +11 -57
  8. package/dist/adapters/GitHubReleaseProvider.js.map +1 -1
  9. package/dist/adapters/RepoFetcher.d.ts +54 -0
  10. package/dist/adapters/RepoFetcher.d.ts.map +1 -0
  11. package/dist/adapters/RepoFetcher.js +75 -0
  12. package/dist/adapters/RepoFetcher.js.map +1 -0
  13. package/dist/distribution/DistributionAssembler.d.ts +123 -0
  14. package/dist/distribution/DistributionAssembler.d.ts.map +1 -0
  15. package/dist/distribution/DistributionAssembler.js +335 -0
  16. package/dist/distribution/DistributionAssembler.js.map +1 -0
  17. package/dist/distribution/createBundle.d.ts +51 -0
  18. package/dist/distribution/createBundle.d.ts.map +1 -0
  19. package/dist/distribution/createBundle.js +47 -0
  20. package/dist/distribution/createBundle.js.map +1 -0
  21. package/dist/distribution/transforms.d.ts +68 -0
  22. package/dist/distribution/transforms.d.ts.map +1 -0
  23. package/dist/distribution/transforms.js +171 -0
  24. package/dist/distribution/transforms.js.map +1 -0
  25. package/dist/index.d.ts +6 -3
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +7 -3
  28. package/dist/index.js.map +1 -1
  29. package/dist/phases/ConfigurePhase.d.ts +18 -0
  30. package/dist/phases/ConfigurePhase.d.ts.map +1 -1
  31. package/dist/phases/ConfigurePhase.js +33 -4
  32. package/dist/phases/ConfigurePhase.js.map +1 -1
  33. package/dist/phases/ScaffoldPhase.d.ts +21 -1
  34. package/dist/phases/ScaffoldPhase.d.ts.map +1 -1
  35. package/dist/phases/ScaffoldPhase.js +80 -16
  36. package/dist/phases/ScaffoldPhase.js.map +1 -1
  37. package/package.json +4 -2
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Assembles a MemberJunction **distribution layout** from a source checkout (a
3
+ * git sparse-checkout or a local working tree) — the typed replacement for the
4
+ * legacy root `CreateMJDistribution.js`.
5
+ *
6
+ * The output is byte-compatible with the bootstrap zip it replaces, so every
7
+ * downstream installer phase (configure/platform/dependencies/migrate/codegen)
8
+ * sees the same on-disk shape it always has:
9
+ *
10
+ * - `packages/MJAPI` → `apps/MJAPI`, `packages/MJExplorer` → `apps/MJExplorer`
11
+ * - `packages/GeneratedEntities` / `packages/GeneratedActions` kept in place
12
+ * - `SQL Scripts` kept (minus `generated/`, `internal_only/`, `install/`), with an
13
+ * empty `generated/` directory marker so CodeGen has somewhere to write
14
+ * - package tsconfigs flattened (no `extends`); `tsc-alias` / `--port` stripped
15
+ * - root `distribution.*` files mapped to `package.json` / `turbo.json` /
16
+ * `mj.config.cjs` / `README.md`, plus `install.config.json` and the update script
17
+ *
18
+ * Environment files are intentionally NOT shipped — the installer's
19
+ * `ConfigurePhase` generates them from resolved config.
20
+ *
21
+ * The assembler first builds a pure-data {@link WriteOp}[] plan, then applies it
22
+ * either to a directory (install) or to a zip via adm-zip (`mj bundle`).
23
+ *
24
+ * @module distribution/DistributionAssembler
25
+ */
26
+ /**
27
+ * A single entry to materialize in the distribution, relative to the distribution root.
28
+ * `emptyDir` represents a directory that must exist even when it has no files (e.g. the
29
+ * CodeGen output folder) — stored as a directory entry in a zip, `mkdir` on disk.
30
+ */
31
+ export type WriteOp = {
32
+ Dest: string;
33
+ Kind: 'copy';
34
+ SourceAbs: string;
35
+ } | {
36
+ Dest: string;
37
+ Kind: 'content';
38
+ Text: string;
39
+ } | {
40
+ Dest: string;
41
+ Kind: 'emptyDir';
42
+ };
43
+ /** Database platform whose migration tree maps to a source directory. */
44
+ export type DbPlatform = 'sqlserver' | 'postgresql';
45
+ /** Inputs for building a distribution plan. */
46
+ export interface AssembleOptions {
47
+ /** Root of the source checkout / working tree. */
48
+ SourceDir: string;
49
+ /** When true, include the migration tree(s) (offline bundles). Install omits them. */
50
+ IncludeMigrations?: boolean;
51
+ /**
52
+ * Which platform's migration tree to include when `IncludeMigrations` is set.
53
+ * Omitted = both `migrations/` (SQL Server) and `migrations-pg/` (PostgreSQL),
54
+ * silently skipping whichever is absent at the source (e.g. an older tag that
55
+ * predates one tree). Set explicitly to ship exactly one — a missing tree then
56
+ * fails loudly because you asked for it by name.
57
+ */
58
+ MigrationPlatform?: DbPlatform;
59
+ }
60
+ /**
61
+ * The repo-relative source paths a sparse fetch must check out so that
62
+ * {@link DistributionAssembler.Plan} has everything it needs: the mapped code
63
+ * directories, the base tsconfigs inlined during flattening, and the root
64
+ * `distribution.*` template files.
65
+ *
66
+ * @param includeMigrations - Add the migration tree(s) (offline bundles).
67
+ * @param migrationPlatform - Narrow to one platform's tree; omitted = both
68
+ * (a sparse fetch tolerates a path that doesn't exist at the ref).
69
+ */
70
+ export declare function distributionSourcePaths(includeMigrations?: boolean, migrationPlatform?: DbPlatform): string[];
71
+ /**
72
+ * Builds and applies the distribution layout plan.
73
+ */
74
+ export declare class DistributionAssembler {
75
+ /**
76
+ * Build the ordered list of {@link WriteOp}s for a distribution. Reads source
77
+ * files for the transform steps but performs no writes.
78
+ *
79
+ * @throws If a required source directory or root file is missing.
80
+ */
81
+ Plan(opts: AssembleOptions): Promise<WriteOp[]>;
82
+ /** Build the plan and write every op into `destDir`. Returns the plan that was applied. */
83
+ AssembleToDir(opts: AssembleOptions, destDir: string): Promise<WriteOp[]>;
84
+ /** Build the plan and write every op into a zip at `zipPath`. Returns the plan that was applied. */
85
+ AssembleToZip(opts: AssembleOptions, zipPath: string): Promise<WriteOp[]>;
86
+ /** Materialize every op into `destDir`, creating parent directories as needed. */
87
+ WriteToDir(ops: readonly WriteOp[], destDir: string): Promise<void>;
88
+ /** Materialize every op into a zip at `zipPath`. */
89
+ WriteToZip(ops: readonly WriteOp[], zipPath: string): Promise<void>;
90
+ /**
91
+ * The mappings to include for this assembly. Migrations are conditional: an
92
+ * explicitly-selected platform is always added (and validated downstream by
93
+ * {@link assertSourcesPresent}), while the default "both" selection includes only
94
+ * the trees that actually exist at the source — so bundling a ref that predates
95
+ * one platform's tree doesn't fail.
96
+ */
97
+ private mappingsFor;
98
+ /** Build the write ops for one directory mapping (raw copies + per-kind transforms). */
99
+ private planMapping;
100
+ /** Re-emit the files that each mapping kind transforms instead of copying verbatim. */
101
+ private transformedFilesFor;
102
+ /** Flattened tsconfig + tsc-alias-stripped package.json for a server package. */
103
+ private serverTransforms;
104
+ /** Flattened Angular tsconfig + port-stripped package.json for MJExplorer. */
105
+ private angularTransforms;
106
+ /** Copy ops for the single-file root mappings. */
107
+ private planRootFiles;
108
+ /** The ignore set for a mapping kind. */
109
+ private ignoreFor;
110
+ /** Recursively list non-ignored files under `absDir`, returning posix relative paths. */
111
+ private collectFiles;
112
+ /** Depth-first walk that skips ignored files and prunes ignored directories. */
113
+ private walk;
114
+ /** True when `rel` matches an ignore pattern (directories also match a `X/**` prefix). */
115
+ private isIgnored;
116
+ /** Verify every mapping's source directory exists (clear failure if the fetch was incomplete). */
117
+ private assertSourcesPresent;
118
+ /** True if a file or directory exists at `target`. */
119
+ private pathExists;
120
+ /** Join a dest prefix and a posix relative path with a single forward slash. */
121
+ private joinPosix;
122
+ }
123
+ //# sourceMappingURL=DistributionAssembler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DistributionAssembler.d.ts","sourceRoot":"","sources":["../../src/distribution/DistributionAssembler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAQH;;;;GAIG;AACH,MAAM,MAAM,OAAO,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA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,uFAAuF;YACzE,mBAAmB;IAajC,iFAAiF;YACnE,gBAAgB;IAU9B,8EAA8E;YAChE,iBAAiB;IAU/B,kDAAkD;IAClD,OAAO,CAAC,aAAa;IAQrB,yCAAyC;IACzC,OAAO,CAAC,SAAS;IAiBjB,yFAAyF;YAC3E,YAAY;IAM1B,gFAAgF;YAClE,IAAI;IAelB,0FAA0F;IAC1F,OAAO,CAAC,SAAS;IAQjB,kGAAkG;YACpF,oBAAoB;IAiBlC,sDAAsD;YACxC,UAAU;IASxB,gFAAgF;IAChF,OAAO,CAAC,SAAS;CAIlB"}
@@ -0,0 +1,335 @@
1
+ /**
2
+ * Assembles a MemberJunction **distribution layout** from a source checkout (a
3
+ * git sparse-checkout or a local working tree) — the typed replacement for the
4
+ * legacy root `CreateMJDistribution.js`.
5
+ *
6
+ * The output is byte-compatible with the bootstrap zip it replaces, so every
7
+ * downstream installer phase (configure/platform/dependencies/migrate/codegen)
8
+ * sees the same on-disk shape it always has:
9
+ *
10
+ * - `packages/MJAPI` → `apps/MJAPI`, `packages/MJExplorer` → `apps/MJExplorer`
11
+ * - `packages/GeneratedEntities` / `packages/GeneratedActions` kept in place
12
+ * - `SQL Scripts` kept (minus `generated/`, `internal_only/`, `install/`), with an
13
+ * empty `generated/` directory marker so CodeGen has somewhere to write
14
+ * - package tsconfigs flattened (no `extends`); `tsc-alias` / `--port` stripped
15
+ * - root `distribution.*` files mapped to `package.json` / `turbo.json` /
16
+ * `mj.config.cjs` / `README.md`, plus `install.config.json` and the update script
17
+ *
18
+ * Environment files are intentionally NOT shipped — the installer's
19
+ * `ConfigurePhase` generates them from resolved config.
20
+ *
21
+ * The assembler first builds a pure-data {@link WriteOp}[] plan, then applies it
22
+ * either to a directory (install) or to a zip via adm-zip (`mj bundle`).
23
+ *
24
+ * @module distribution/DistributionAssembler
25
+ */
26
+ import path from 'node:path';
27
+ import { readdir, readFile, mkdir, writeFile, copyFile, stat } from 'node:fs/promises';
28
+ import { minimatch } from 'minimatch';
29
+ import AdmZip from 'adm-zip';
30
+ import { transformServerTsconfig, transformAngularTsconfig, stripTscAliasFromPackageJson, removePortFlagsFromPackageJson } from './transforms.js';
31
+ /** Ignore patterns shared by every package/app directory (gitignored artifacts + secrets). */
32
+ const COMMON_IGNORE = [
33
+ 'node_modules/**',
34
+ 'dist/**',
35
+ '.turbo/**',
36
+ '.vscode/**',
37
+ '.angular/**',
38
+ 'internal_only/**',
39
+ 'package-lock.json',
40
+ '.env',
41
+ 'mj.config.js',
42
+ '*.output.txt',
43
+ '*.log',
44
+ '.*',
45
+ ];
46
+ /** Server packages re-emit a flattened tsconfig + tsc-alias-stripped package.json, so those are excluded from the raw copy. */
47
+ const SERVER_IGNORE = [...COMMON_IGNORE, 'src/generated/**', 'tsconfig.json', 'package.json'];
48
+ /** MJExplorer re-emits a flattened tsconfig + port-stripped package.json; environment files come from ConfigurePhase. */
49
+ const ANGULAR_IGNORE = [
50
+ ...COMMON_IGNORE,
51
+ 'src/app/generated/**',
52
+ 'src/environments/**',
53
+ 'kendo-ui-license.txt',
54
+ 'tsconfig.json',
55
+ 'package.json',
56
+ ];
57
+ /** SQL Scripts uses its own exclusion list (generated SQL is regenerated by CodeGen). */
58
+ const SQLSCRIPTS_IGNORE = ['_all_entities.sql', '_all_entities.permissions.sql', 'install/**', 'internal_only/**', 'generated/**'];
59
+ /** Migrations bundle excludes documentation and backup files. */
60
+ const MIGRATIONS_IGNORE = [...COMMON_IGNORE, '**/*.md', '**/*.backup'];
61
+ /** Directory mappings always included in a distribution. */
62
+ const BASE_MAPPINGS = [
63
+ { SourceRel: 'SQL Scripts', DestRel: 'SQL Scripts', Kind: 'sqlscripts' },
64
+ { SourceRel: 'packages/MJAPI', DestRel: 'apps/MJAPI', Kind: 'server' },
65
+ { SourceRel: 'packages/MJExplorer', DestRel: 'apps/MJExplorer', Kind: 'angular' },
66
+ { SourceRel: 'packages/GeneratedEntities', DestRel: 'packages/GeneratedEntities', Kind: 'server' },
67
+ { SourceRel: 'packages/GeneratedActions', DestRel: 'packages/GeneratedActions', Kind: 'server' },
68
+ ];
69
+ /** Single-file root mappings (source → distribution root). */
70
+ const ROOT_FILES = [
71
+ { SourceRel: 'distribution.package.json', DestRel: 'package.json' },
72
+ { SourceRel: 'distribution.turbo.json', DestRel: 'turbo.json' },
73
+ { SourceRel: 'distribution.config.cjs', DestRel: 'mj.config.cjs' },
74
+ { SourceRel: 'distribution.README.md', DestRel: 'README.md' },
75
+ { SourceRel: 'install.config.json', DestRel: 'install.config.json' },
76
+ { SourceRel: 'packages/Update_MemberJunction_Packages_To_Latest.ps1', DestRel: 'Update_MemberJunction_Packages_To_Latest.ps1' },
77
+ ];
78
+ /** Base tsconfig filenames the package configs `extends`, read once and inlined. */
79
+ const SERVER_BASE_TSCONFIG = 'tsconfig.server.json';
80
+ const ANGULAR_BASE_TSCONFIG = 'tsconfig.angular.json';
81
+ /** Source directory holding each DB platform's migration tree. */
82
+ const MIGRATION_DIRS = {
83
+ sqlserver: 'migrations',
84
+ postgresql: 'migrations-pg',
85
+ };
86
+ /** Migration source dirs for a platform selection; an omitted platform = both trees. */
87
+ function migrationDirsFor(platform) {
88
+ return platform ? [MIGRATION_DIRS[platform]] : [MIGRATION_DIRS.sqlserver, MIGRATION_DIRS.postgresql];
89
+ }
90
+ /**
91
+ * The repo-relative source paths a sparse fetch must check out so that
92
+ * {@link DistributionAssembler.Plan} has everything it needs: the mapped code
93
+ * directories, the base tsconfigs inlined during flattening, and the root
94
+ * `distribution.*` template files.
95
+ *
96
+ * @param includeMigrations - Add the migration tree(s) (offline bundles).
97
+ * @param migrationPlatform - Narrow to one platform's tree; omitted = both
98
+ * (a sparse fetch tolerates a path that doesn't exist at the ref).
99
+ */
100
+ export function distributionSourcePaths(includeMigrations = false, migrationPlatform) {
101
+ const dirs = BASE_MAPPINGS.map((mapping) => mapping.SourceRel);
102
+ if (includeMigrations) {
103
+ dirs.push(...migrationDirsFor(migrationPlatform));
104
+ }
105
+ return [...dirs, SERVER_BASE_TSCONFIG, ANGULAR_BASE_TSCONFIG, ...ROOT_FILES.map((file) => file.SourceRel)];
106
+ }
107
+ /**
108
+ * Builds and applies the distribution layout plan.
109
+ */
110
+ export class DistributionAssembler {
111
+ /**
112
+ * Build the ordered list of {@link WriteOp}s for a distribution. Reads source
113
+ * files for the transform steps but performs no writes.
114
+ *
115
+ * @throws If a required source directory or root file is missing.
116
+ */
117
+ async Plan(opts) {
118
+ const mappings = await this.mappingsFor(opts);
119
+ await this.assertSourcesPresent(opts.SourceDir, mappings);
120
+ const ops = [];
121
+ for (const mapping of mappings) {
122
+ ops.push(...(await this.planMapping(opts.SourceDir, mapping)));
123
+ }
124
+ ops.push(...this.planRootFiles(opts.SourceDir));
125
+ return ops;
126
+ }
127
+ /** Build the plan and write every op into `destDir`. Returns the plan that was applied. */
128
+ async AssembleToDir(opts, destDir) {
129
+ const ops = await this.Plan(opts);
130
+ await this.WriteToDir(ops, destDir);
131
+ return ops;
132
+ }
133
+ /** Build the plan and write every op into a zip at `zipPath`. Returns the plan that was applied. */
134
+ async AssembleToZip(opts, zipPath) {
135
+ const ops = await this.Plan(opts);
136
+ await this.WriteToZip(ops, zipPath);
137
+ return ops;
138
+ }
139
+ /** Materialize every op into `destDir`, creating parent directories as needed. */
140
+ async WriteToDir(ops, destDir) {
141
+ for (const op of ops) {
142
+ const dest = path.join(destDir, ...op.Dest.split('/'));
143
+ if (op.Kind === 'emptyDir') {
144
+ await mkdir(dest, { recursive: true });
145
+ continue;
146
+ }
147
+ await mkdir(path.dirname(dest), { recursive: true });
148
+ if (op.Kind === 'copy') {
149
+ await copyFile(op.SourceAbs, dest);
150
+ }
151
+ else {
152
+ await writeFile(dest, op.Text, 'utf-8');
153
+ }
154
+ }
155
+ }
156
+ /** Materialize every op into a zip at `zipPath`. */
157
+ async WriteToZip(ops, zipPath) {
158
+ const zip = new AdmZip();
159
+ for (const op of ops) {
160
+ if (op.Kind === 'emptyDir') {
161
+ zip.addFile(`${op.Dest}/`, Buffer.alloc(0)); // trailing slash → directory entry
162
+ continue;
163
+ }
164
+ const slash = op.Dest.lastIndexOf('/');
165
+ const folder = slash >= 0 ? op.Dest.slice(0, slash) : '';
166
+ const name = slash >= 0 ? op.Dest.slice(slash + 1) : op.Dest;
167
+ if (op.Kind === 'copy') {
168
+ zip.addLocalFile(op.SourceAbs, folder, name);
169
+ }
170
+ else {
171
+ zip.addFile(op.Dest, Buffer.from(op.Text, 'utf-8'));
172
+ }
173
+ }
174
+ await mkdir(path.dirname(path.resolve(zipPath)), { recursive: true });
175
+ zip.writeZip(zipPath);
176
+ }
177
+ // ---------------------------------------------------------------------------
178
+ // Plan construction
179
+ // ---------------------------------------------------------------------------
180
+ /**
181
+ * The mappings to include for this assembly. Migrations are conditional: an
182
+ * explicitly-selected platform is always added (and validated downstream by
183
+ * {@link assertSourcesPresent}), while the default "both" selection includes only
184
+ * the trees that actually exist at the source — so bundling a ref that predates
185
+ * one platform's tree doesn't fail.
186
+ */
187
+ async mappingsFor(opts) {
188
+ const mappings = [...BASE_MAPPINGS];
189
+ if (!(opts.IncludeMigrations ?? false)) {
190
+ return mappings;
191
+ }
192
+ const explicit = opts.MigrationPlatform != null;
193
+ for (const dir of migrationDirsFor(opts.MigrationPlatform)) {
194
+ if (explicit || (await this.pathExists(path.join(opts.SourceDir, dir)))) {
195
+ mappings.push({ SourceRel: dir, DestRel: dir, Kind: 'migrations' });
196
+ }
197
+ }
198
+ return mappings;
199
+ }
200
+ /** Build the write ops for one directory mapping (raw copies + per-kind transforms). */
201
+ async planMapping(sourceDir, mapping) {
202
+ const absSource = path.join(sourceDir, mapping.SourceRel);
203
+ const files = await this.collectFiles(absSource, this.ignoreFor(mapping.Kind));
204
+ const ops = files.map((rel) => ({
205
+ Dest: this.joinPosix(mapping.DestRel, rel),
206
+ Kind: 'copy',
207
+ SourceAbs: path.join(absSource, ...rel.split('/')),
208
+ }));
209
+ ops.push(...(await this.transformedFilesFor(sourceDir, absSource, mapping)));
210
+ return ops;
211
+ }
212
+ /** Re-emit the files that each mapping kind transforms instead of copying verbatim. */
213
+ async transformedFilesFor(sourceDir, absSource, mapping) {
214
+ if (mapping.Kind === 'server') {
215
+ return this.serverTransforms(sourceDir, absSource, mapping.DestRel);
216
+ }
217
+ if (mapping.Kind === 'angular') {
218
+ return this.angularTransforms(sourceDir, absSource, mapping.DestRel);
219
+ }
220
+ if (mapping.Kind === 'sqlscripts') {
221
+ return [{ Dest: this.joinPosix(mapping.DestRel, 'generated'), Kind: 'emptyDir' }];
222
+ }
223
+ return [];
224
+ }
225
+ /** Flattened tsconfig + tsc-alias-stripped package.json for a server package. */
226
+ async serverTransforms(sourceDir, absSource, destRel) {
227
+ const base = await readFile(path.join(sourceDir, SERVER_BASE_TSCONFIG), 'utf-8');
228
+ const tsconfig = await readFile(path.join(absSource, 'tsconfig.json'), 'utf-8');
229
+ const pkg = await readFile(path.join(absSource, 'package.json'), 'utf-8');
230
+ return [
231
+ { Dest: this.joinPosix(destRel, 'tsconfig.json'), Kind: 'content', Text: transformServerTsconfig(tsconfig, base) },
232
+ { Dest: this.joinPosix(destRel, 'package.json'), Kind: 'content', Text: stripTscAliasFromPackageJson(pkg) },
233
+ ];
234
+ }
235
+ /** Flattened Angular tsconfig + port-stripped package.json for MJExplorer. */
236
+ async angularTransforms(sourceDir, absSource, destRel) {
237
+ const base = await readFile(path.join(sourceDir, ANGULAR_BASE_TSCONFIG), 'utf-8');
238
+ const tsconfig = await readFile(path.join(absSource, 'tsconfig.json'), 'utf-8');
239
+ const pkg = await readFile(path.join(absSource, 'package.json'), 'utf-8');
240
+ return [
241
+ { Dest: this.joinPosix(destRel, 'tsconfig.json'), Kind: 'content', Text: transformAngularTsconfig(tsconfig, base) },
242
+ { Dest: this.joinPosix(destRel, 'package.json'), Kind: 'content', Text: removePortFlagsFromPackageJson(pkg) },
243
+ ];
244
+ }
245
+ /** Copy ops for the single-file root mappings. */
246
+ planRootFiles(sourceDir) {
247
+ return ROOT_FILES.map((file) => ({
248
+ Dest: file.DestRel,
249
+ Kind: 'copy',
250
+ SourceAbs: path.join(sourceDir, ...file.SourceRel.split('/')),
251
+ }));
252
+ }
253
+ /** The ignore set for a mapping kind. */
254
+ ignoreFor(kind) {
255
+ switch (kind) {
256
+ case 'server':
257
+ return SERVER_IGNORE;
258
+ case 'angular':
259
+ return ANGULAR_IGNORE;
260
+ case 'sqlscripts':
261
+ return SQLSCRIPTS_IGNORE;
262
+ case 'migrations':
263
+ return MIGRATIONS_IGNORE;
264
+ }
265
+ }
266
+ // ---------------------------------------------------------------------------
267
+ // Filesystem helpers
268
+ // ---------------------------------------------------------------------------
269
+ /** Recursively list non-ignored files under `absDir`, returning posix relative paths. */
270
+ async collectFiles(absDir, ignore) {
271
+ const out = [];
272
+ await this.walk(absDir, absDir, ignore, out);
273
+ return out.sort();
274
+ }
275
+ /** Depth-first walk that skips ignored files and prunes ignored directories. */
276
+ async walk(root, current, ignore, out) {
277
+ const entries = await readdir(current, { withFileTypes: true });
278
+ for (const entry of entries) {
279
+ const abs = path.join(current, entry.name);
280
+ const rel = path.relative(root, abs).split(path.sep).join('/');
281
+ if (entry.isDirectory()) {
282
+ if (!this.isIgnored(rel, ignore, true)) {
283
+ await this.walk(root, abs, ignore, out);
284
+ }
285
+ }
286
+ else if (entry.isFile() && !this.isIgnored(rel, ignore, false)) {
287
+ out.push(rel);
288
+ }
289
+ }
290
+ }
291
+ /** True when `rel` matches an ignore pattern (directories also match a `X/**` prefix). */
292
+ isIgnored(rel, ignore, isDir) {
293
+ for (const pattern of ignore) {
294
+ if (minimatch(rel, pattern, { dot: true }))
295
+ return true;
296
+ if (isDir && pattern.endsWith('/**') && minimatch(rel, pattern.slice(0, -3), { dot: true }))
297
+ return true;
298
+ }
299
+ return false;
300
+ }
301
+ /** Verify every mapping's source directory exists (clear failure if the fetch was incomplete). */
302
+ async assertSourcesPresent(sourceDir, mappings) {
303
+ const missing = [];
304
+ for (const mapping of mappings) {
305
+ if (!(await this.pathExists(path.join(sourceDir, mapping.SourceRel)))) {
306
+ missing.push(mapping.SourceRel);
307
+ }
308
+ }
309
+ for (const file of ROOT_FILES) {
310
+ if (!(await this.pathExists(path.join(sourceDir, ...file.SourceRel.split('/'))))) {
311
+ missing.push(file.SourceRel);
312
+ }
313
+ }
314
+ if (missing.length > 0) {
315
+ throw new Error(`Distribution source is missing required path(s): ${missing.join(', ')}`);
316
+ }
317
+ }
318
+ /** True if a file or directory exists at `target`. */
319
+ async pathExists(target) {
320
+ try {
321
+ await stat(target);
322
+ return true;
323
+ }
324
+ catch {
325
+ return false;
326
+ }
327
+ }
328
+ /** Join a dest prefix and a posix relative path with a single forward slash. */
329
+ joinPosix(prefix, rel) {
330
+ if (prefix === '')
331
+ return rel;
332
+ return `${prefix}/${rel}`;
333
+ }
334
+ }
335
+ //# sourceMappingURL=DistributionAssembler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DistributionAssembler.js","sourceRoot":"","sources":["../../src/distribution/DistributionAssembler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACvF,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,4BAA4B,EAAE,8BAA8B,EAAE,MAAM,iBAAiB,CAAC;AA4ClJ,8FAA8F;AAC9F,MAAM,aAAa,GAAsB;IACvC,iBAAiB;IACjB,SAAS;IACT,WAAW;IACX,YAAY;IACZ,aAAa;IACb,kBAAkB;IAClB,mBAAmB;IACnB,MAAM;IACN,cAAc;IACd,cAAc;IACd,OAAO;IACP,IAAI;CACL,CAAC;AAEF,+HAA+H;AAC/H,MAAM,aAAa,GAA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,CAAC,CAAC;YACnB,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,gFAAgF;IACxE,SAAS,CAAC,MAAc,EAAE,GAAW;QAC3C,IAAI,MAAM,KAAK,EAAE;YAAE,OAAO,GAAG,CAAC;QAC9B,OAAO,GAAG,MAAM,IAAI,GAAG,EAAE,CAAC;IAC5B,CAAC;CACF"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Produces a self-contained MemberJunction distribution zip on demand — the
3
+ * offline/air-gapped convenience that replaces the committed bootstrap zip.
4
+ *
5
+ * The zip is assembled from either a remote ref (fetched via sparse-checkout) or
6
+ * a local working tree, using the same {@link DistributionAssembler} the install
7
+ * path uses, so a bundle is byte-equivalent to what `mj install` would lay down.
8
+ *
9
+ * @module distribution/createBundle
10
+ */
11
+ import { type DbPlatform } from './DistributionAssembler.js';
12
+ /** Inputs for {@link createDistributionBundle}. Provide exactly one of `SourceDir` or `Ref`. */
13
+ export interface CreateBundleOptions {
14
+ /** Absolute path to write the output zip. */
15
+ Out: string;
16
+ /** Branch/tag to fetch and bundle (e.g. `'main'`, `'v5.38.0'`). Ignored when `SourceDir` is set. */
17
+ Ref?: string;
18
+ /** Clone URL when bundling from a ref (defaults to the canonical MJ repo). */
19
+ RepoUrl?: string;
20
+ /** Local working-tree directory to bundle instead of fetching from a ref. */
21
+ SourceDir?: string;
22
+ /** Include the migration tree(s) so an air-gapped `mj migrate` can run offline. */
23
+ IncludeMigrations?: boolean;
24
+ /**
25
+ * Narrow the bundled migrations to one platform's tree when `IncludeMigrations`
26
+ * is set. Omitted = both `migrations/` (SQL Server) and `migrations-pg/`
27
+ * (PostgreSQL), so the bundle works against either database offline.
28
+ */
29
+ MigrationPlatform?: DbPlatform;
30
+ }
31
+ /** Result of {@link createDistributionBundle}. */
32
+ export interface CreateBundleResult {
33
+ /** Absolute path of the written zip. */
34
+ Out: string;
35
+ /** Number of entries written into the zip. */
36
+ EntryCount: number;
37
+ /** Where the source came from. */
38
+ Source: 'local' | 'fetch';
39
+ /** True when a ref fetch fell back from blobless partial clone to a full sparse clone. */
40
+ UsedFallback: boolean;
41
+ }
42
+ /**
43
+ * Assemble a distribution zip from a local source dir or a fetched ref.
44
+ *
45
+ * SIDE EFFECTS: writes the zip at `opts.Out`; when fetching, clones over the
46
+ * network into a temp dir that is always cleaned up.
47
+ *
48
+ * @throws If neither `SourceDir` nor `Ref` is provided, or if fetch/assembly fails.
49
+ */
50
+ export declare function createDistributionBundle(opts: CreateBundleOptions): Promise<CreateBundleResult>;
51
+ //# sourceMappingURL=createBundle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createBundle.d.ts","sourceRoot":"","sources":["../../src/distribution/createBundle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAkD,KAAK,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAK7G,gGAAgG;AAChG,MAAM,WAAW,mBAAmB;IAClC,6CAA6C;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,oGAAoG;IACpG,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,8EAA8E;IAC9E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6EAA6E;IAC7E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mFAAmF;IACnF,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,UAAU,CAAC;CAChC;AAED,kDAAkD;AAClD,MAAM,WAAW,kBAAkB;IACjC,wCAAwC;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,8CAA8C;IAC9C,UAAU,EAAE,MAAM,CAAC;IACnB,kCAAkC;IAClC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC;IAC1B,0FAA0F;IAC1F,YAAY,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;;GAOG;AACH,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA6BrG"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Produces a self-contained MemberJunction distribution zip on demand — the
3
+ * offline/air-gapped convenience that replaces the committed bootstrap zip.
4
+ *
5
+ * The zip is assembled from either a remote ref (fetched via sparse-checkout) or
6
+ * a local working tree, using the same {@link DistributionAssembler} the install
7
+ * path uses, so a bundle is byte-equivalent to what `mj install` would lay down.
8
+ *
9
+ * @module distribution/createBundle
10
+ */
11
+ import { RepoFetcher } from '../adapters/RepoFetcher.js';
12
+ import { DistributionAssembler, distributionSourcePaths } from './DistributionAssembler.js';
13
+ /** Default canonical MemberJunction clone URL used when bundling from a ref. */
14
+ const DEFAULT_REPO_URL = 'https://github.com/MemberJunction/MJ.git';
15
+ /**
16
+ * Assemble a distribution zip from a local source dir or a fetched ref.
17
+ *
18
+ * SIDE EFFECTS: writes the zip at `opts.Out`; when fetching, clones over the
19
+ * network into a temp dir that is always cleaned up.
20
+ *
21
+ * @throws If neither `SourceDir` nor `Ref` is provided, or if fetch/assembly fails.
22
+ */
23
+ export async function createDistributionBundle(opts) {
24
+ const assembler = new DistributionAssembler();
25
+ const includeMigrations = opts.IncludeMigrations ?? false;
26
+ const migrationPlatform = opts.MigrationPlatform;
27
+ if (opts.SourceDir) {
28
+ const ops = await assembler.AssembleToZip({ SourceDir: opts.SourceDir, IncludeMigrations: includeMigrations, MigrationPlatform: migrationPlatform }, opts.Out);
29
+ return { Out: opts.Out, EntryCount: ops.length, Source: 'local', UsedFallback: false };
30
+ }
31
+ if (!opts.Ref) {
32
+ throw new Error('createDistributionBundle requires either SourceDir or Ref');
33
+ }
34
+ const fetched = await new RepoFetcher().FetchPaths({
35
+ RepoUrl: opts.RepoUrl ?? DEFAULT_REPO_URL,
36
+ Ref: opts.Ref,
37
+ Paths: distributionSourcePaths(includeMigrations, migrationPlatform),
38
+ });
39
+ try {
40
+ const ops = await assembler.AssembleToZip({ SourceDir: fetched.Dir, IncludeMigrations: includeMigrations, MigrationPlatform: migrationPlatform }, opts.Out);
41
+ return { Out: opts.Out, EntryCount: ops.length, Source: 'fetch', UsedFallback: fetched.UsedFallback };
42
+ }
43
+ finally {
44
+ await fetched.Cleanup();
45
+ }
46
+ }
47
+ //# sourceMappingURL=createBundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createBundle.js","sourceRoot":"","sources":["../../src/distribution/createBundle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAmB,MAAM,4BAA4B,CAAC;AAE7G,gFAAgF;AAChF,MAAM,gBAAgB,GAAG,0CAA0C,CAAC;AAkCpE;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,IAAyB;IACtE,MAAM,SAAS,GAAG,IAAI,qBAAqB,EAAE,CAAC;IAC9C,MAAM,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,IAAI,KAAK,CAAC;IAC1D,MAAM,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,CAAC;IAEjD,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;QACnB,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,aAAa,CACvC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,EACzG,IAAI,CAAC,GAAG,CACT,CAAC;QACF,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;IACzF,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;IAC/E,CAAC;IAED,MAA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