castle-web-cli 0.4.136 → 0.4.138
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/init.js +11 -1
- package/dist/save-deck.js +23 -7
- package/package.json +1 -1
package/dist/init.js
CHANGED
|
@@ -3,7 +3,7 @@ import * as path from 'path';
|
|
|
3
3
|
import { COMMON_INSTRUCTIONS } from './commonInstructions.js';
|
|
4
4
|
import { installDeps } from './install.js';
|
|
5
5
|
import { deckMainFile, deckStarterScene } from './castleJson.js';
|
|
6
|
-
import { addImportTo, IMPORTS_DIR, lockImportTree } from './imports.js';
|
|
6
|
+
import { addImportTo, IMPORTS_DIR, lockImportTree, restoreMissingImports, syncImportDependencies, } from './imports.js';
|
|
7
7
|
import { discardParentSource, fetchParentSource, unpackParentSource, writeRemixIdentity, } from './remix.js';
|
|
8
8
|
import { getCliEntryPath, getKitsDir, getRepoRoot, getSdkPackagePath, toPosixPath, } from './localPaths.js';
|
|
9
9
|
import { serve } from './serve.js';
|
|
@@ -470,6 +470,16 @@ async function scaffoldFromRemix(parentDeckId, projectDir, identity) {
|
|
|
470
470
|
}
|
|
471
471
|
else {
|
|
472
472
|
await unpackParentSource(source, projectDir);
|
|
473
|
+
// `imports/` is left out of the source archive, so a copied deck arrives
|
|
474
|
+
// with its pins and none of the files -- same as get-deck, which leaves
|
|
475
|
+
// this to `install`. Its declared deps then have to reach package.json
|
|
476
|
+
// before the install below.
|
|
477
|
+
for (const alias of await restoreMissingImports(projectDir)) {
|
|
478
|
+
console.log(`Restored import ${alias}`);
|
|
479
|
+
}
|
|
480
|
+
for (const dep of syncImportDependencies(projectDir)) {
|
|
481
|
+
console.log(`Added dependency ${dep} from an import`);
|
|
482
|
+
}
|
|
473
483
|
}
|
|
474
484
|
}
|
|
475
485
|
finally {
|
package/dist/save-deck.js
CHANGED
|
@@ -17,11 +17,17 @@ export const SOURCE_ARCHIVE_EXCLUDES = ['node_modules', 'dist', '.castle', '.git
|
|
|
17
17
|
// (`-tzf`), where the output IS the answer. Packing and unpacking ignore it.
|
|
18
18
|
export function runTar(args, opts = {}) {
|
|
19
19
|
return new Promise((resolve, reject) => {
|
|
20
|
-
const child = spawn('tar', args, {
|
|
20
|
+
const child = spawn('tar', args, {
|
|
21
|
+
stdio: ['ignore', opts.capture ? 'pipe' : 'ignore', 'pipe'],
|
|
22
|
+
});
|
|
21
23
|
let stdout = '';
|
|
22
24
|
let stderr = '';
|
|
23
|
-
child.stdout?.on('data', (chunk) => {
|
|
24
|
-
|
|
25
|
+
child.stdout?.on('data', (chunk) => {
|
|
26
|
+
stdout += chunk.toString();
|
|
27
|
+
});
|
|
28
|
+
child.stderr?.on('data', (chunk) => {
|
|
29
|
+
stderr += chunk.toString();
|
|
30
|
+
});
|
|
25
31
|
child.on('error', reject);
|
|
26
32
|
child.on('close', (code) => {
|
|
27
33
|
if (code !== 0) {
|
|
@@ -46,7 +52,9 @@ export async function archiveSource(projectDir) {
|
|
|
46
52
|
try {
|
|
47
53
|
fs.unlinkSync(tmpFile);
|
|
48
54
|
}
|
|
49
|
-
catch {
|
|
55
|
+
catch {
|
|
56
|
+
/* nothing to clean */
|
|
57
|
+
}
|
|
50
58
|
}
|
|
51
59
|
}
|
|
52
60
|
async function uploadSource(projectDir, deckId) {
|
|
@@ -175,8 +183,8 @@ export async function saveDeck(dir, opts = {}) {
|
|
|
175
183
|
}
|
|
176
184
|
// `--visibility` arrives as an unchecked string from the command line, so the
|
|
177
185
|
// declared type is no guarantee -- widen to validate what actually came in.
|
|
178
|
-
const requested = opts.visibility
|
|
179
|
-
if (requested !== 'unlisted' && requested !== 'private') {
|
|
186
|
+
const requested = opts.visibility;
|
|
187
|
+
if (requested !== undefined && requested !== 'unlisted' && requested !== 'private') {
|
|
180
188
|
console.error(`Invalid visibility "${requested}". Use unlisted or private.`);
|
|
181
189
|
process.exit(1);
|
|
182
190
|
}
|
|
@@ -220,7 +228,15 @@ export async function saveDeck(dir, opts = {}) {
|
|
|
220
228
|
throw new Error(`Upload failed: HTTP ${s3Res.status}`);
|
|
221
229
|
}
|
|
222
230
|
const title = opts.title ?? castleJson?.title ?? path.basename(path.resolve(projectDir));
|
|
223
|
-
const deckInput = { deckId, title
|
|
231
|
+
const deckInput = { deckId, title };
|
|
232
|
+
// Omitted unless asked for, or the deck is new and needs one: updateDeckV2
|
|
233
|
+
// only touches visibility when it is sent, so a deck the creator published
|
|
234
|
+
// from the app stays public instead of being knocked down to unlisted by a
|
|
235
|
+
// routine save. This CLI still cannot make a deck public.
|
|
236
|
+
if (visibility)
|
|
237
|
+
deckInput.visibility = visibility;
|
|
238
|
+
else if (isNew)
|
|
239
|
+
deckInput.visibility = 'unlisted';
|
|
224
240
|
if (opts.caption !== undefined)
|
|
225
241
|
deckInput.caption = opts.caption;
|
|
226
242
|
const backgroundImageFileId = await uploadLocalCover(projectDir);
|