@miranda0808/maya-codex 0.1.0 → 0.1.1
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/README.md +39 -30
- package/package.json +1 -1
- package/payload/.env.example +9 -0
- package/payload/tools/meta/README.md +58 -55
- package/payload/tools/meta/meta-fetch.ps1 +404 -323
- package/payload/tools/meta/meta-fetch.test.ps1 +94 -38
- package/vendor/shared-installer/manifests/common-files.json +14 -13
- package/vendor/shared-installer/src/fs.js +136 -105
- package/vendor/shared-installer/src/install.js +168 -157
|
@@ -1,157 +1,168 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const path = require("node:path");
|
|
4
|
-
const { renderBootstrap } = require("./bootstrap");
|
|
5
|
-
const {
|
|
6
|
-
assertExistingDirectory,
|
|
7
|
-
copyOpaqueFile,
|
|
8
|
-
ensureDirectory,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
writeTextFile,
|
|
16
|
-
} = require("./fs");
|
|
17
|
-
const { loadManifest, resolveInstallerRoot, resolvePayloadRoot } = require("./manifest");
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
await
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const path = require("node:path");
|
|
4
|
+
const { renderBootstrap } = require("./bootstrap");
|
|
5
|
+
const {
|
|
6
|
+
assertExistingDirectory,
|
|
7
|
+
copyOpaqueFile,
|
|
8
|
+
ensureDirectory,
|
|
9
|
+
ensureGitignoreEntries,
|
|
10
|
+
fromPosixPath,
|
|
11
|
+
joinPosixPath,
|
|
12
|
+
listFilesRecursive,
|
|
13
|
+
pathExists,
|
|
14
|
+
resolveTargetDirectory,
|
|
15
|
+
writeTextFile,
|
|
16
|
+
} = require("./fs");
|
|
17
|
+
const { loadManifest, resolveInstallerRoot, resolvePayloadRoot } = require("./manifest");
|
|
18
|
+
|
|
19
|
+
const META_GITIGNORE_ENTRIES = [".env", ".env.local"];
|
|
20
|
+
|
|
21
|
+
async function expandManifestFiles(files, context) {
|
|
22
|
+
const operations = [];
|
|
23
|
+
|
|
24
|
+
for (const entry of files) {
|
|
25
|
+
const sourceBase = entry.template ? context.installerRoot : context.payloadRoot;
|
|
26
|
+
const sourceRoot = fromPosixPath(sourceBase, entry.source);
|
|
27
|
+
const sourceDetails = await require("node:fs/promises").stat(sourceRoot);
|
|
28
|
+
|
|
29
|
+
if (sourceDetails.isDirectory()) {
|
|
30
|
+
const children = await listFilesRecursive(sourceRoot);
|
|
31
|
+
|
|
32
|
+
for (const child of children) {
|
|
33
|
+
const destinationRelative = joinPosixPath(entry.destination, child);
|
|
34
|
+
operations.push({
|
|
35
|
+
destinationPath: fromPosixPath(context.targetDirectory, destinationRelative),
|
|
36
|
+
destinationRelative,
|
|
37
|
+
sourcePath: path.join(sourceRoot, ...child.split("/")),
|
|
38
|
+
sourceRelative: joinPosixPath(entry.source, child),
|
|
39
|
+
template: false,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
operations.push({
|
|
47
|
+
destinationPath: fromPosixPath(context.targetDirectory, entry.destination),
|
|
48
|
+
destinationRelative: entry.destination,
|
|
49
|
+
sourcePath: sourceRoot,
|
|
50
|
+
sourceRelative: entry.source,
|
|
51
|
+
template: entry.template,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return operations;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async function buildInstallPlan(options = {}) {
|
|
59
|
+
if (!options.host) {
|
|
60
|
+
throw new Error("A host id is required.");
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const installerRoot = resolveInstallerRoot(options);
|
|
64
|
+
const payloadRoot = resolvePayloadRoot(options);
|
|
65
|
+
const targetDirectory = resolveTargetDirectory({ cwd: options.cwd, target: options.target });
|
|
66
|
+
await assertExistingDirectory(targetDirectory);
|
|
67
|
+
|
|
68
|
+
const commonManifest = await loadManifest("common", { installerRoot });
|
|
69
|
+
const hostManifest = await loadManifest(options.host, { installerRoot });
|
|
70
|
+
const operations = [
|
|
71
|
+
...(await expandManifestFiles(commonManifest.files, { installerRoot, payloadRoot, targetDirectory })),
|
|
72
|
+
...(await expandManifestFiles(hostManifest.files, { installerRoot, payloadRoot, targetDirectory })),
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
const plannedOperations = [];
|
|
76
|
+
|
|
77
|
+
for (const operation of operations) {
|
|
78
|
+
plannedOperations.push({
|
|
79
|
+
...operation,
|
|
80
|
+
exists: await pathExists(operation.destinationPath),
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const conflicts = plannedOperations
|
|
85
|
+
.filter((operation) => operation.exists)
|
|
86
|
+
.map((operation) => operation.destinationRelative);
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
conflicts,
|
|
90
|
+
dryRun: Boolean(options.dryRun),
|
|
91
|
+
force: Boolean(options.force),
|
|
92
|
+
host: options.host,
|
|
93
|
+
installerRoot,
|
|
94
|
+
manifests: {
|
|
95
|
+
common: commonManifest.manifestPath,
|
|
96
|
+
host: hostManifest.manifestPath,
|
|
97
|
+
},
|
|
98
|
+
operations: plannedOperations,
|
|
99
|
+
payloadRoot,
|
|
100
|
+
targetDirectory,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function summarizePlan(plan) {
|
|
105
|
+
return {
|
|
106
|
+
conflicts: [...plan.conflicts],
|
|
107
|
+
dryRun: plan.dryRun,
|
|
108
|
+
force: plan.force,
|
|
109
|
+
host: plan.host,
|
|
110
|
+
manifests: { ...plan.manifests },
|
|
111
|
+
operations: plan.operations.map((operation) => ({
|
|
112
|
+
destinationRelative: operation.destinationRelative,
|
|
113
|
+
exists: operation.exists,
|
|
114
|
+
mode: operation.template ? "template" : "copy",
|
|
115
|
+
sourceRelative: operation.sourceRelative,
|
|
116
|
+
})),
|
|
117
|
+
targetDirectory: plan.targetDirectory,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
async function installMaya(options = {}) {
|
|
122
|
+
const plan = await buildInstallPlan(options);
|
|
123
|
+
|
|
124
|
+
if (plan.conflicts.length > 0 && !plan.force && !plan.dryRun) {
|
|
125
|
+
throw new Error(
|
|
126
|
+
`Refusing to overwrite files that already exists without --force: ${plan.conflicts.join(", ")}`,
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (plan.dryRun) {
|
|
131
|
+
return summarizePlan(plan);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const writtenFiles = [];
|
|
135
|
+
|
|
136
|
+
for (const operation of plan.operations) {
|
|
137
|
+
await ensureDirectory(path.dirname(operation.destinationPath));
|
|
138
|
+
|
|
139
|
+
if (operation.template) {
|
|
140
|
+
const content = await renderBootstrap(operation, { host: plan.host });
|
|
141
|
+
await writeTextFile(operation.destinationPath, content);
|
|
142
|
+
} else {
|
|
143
|
+
await copyOpaqueFile(operation.sourcePath, operation.destinationPath);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
writtenFiles.push(operation.destinationRelative);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const gitignoreResult = await ensureGitignoreEntries(
|
|
150
|
+
path.join(plan.targetDirectory, ".gitignore"),
|
|
151
|
+
META_GITIGNORE_ENTRIES,
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
if (gitignoreResult.changed) {
|
|
155
|
+
writtenFiles.push(".gitignore");
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return {
|
|
159
|
+
...summarizePlan(plan),
|
|
160
|
+
writtenFiles,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
module.exports = {
|
|
165
|
+
buildInstallPlan,
|
|
166
|
+
installMaya,
|
|
167
|
+
summarizePlan,
|
|
168
|
+
};
|