castle-web-cli 0.4.137 → 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.
Files changed (2) hide show
  1. package/dist/save-deck.js +23 -7
  2. package/package.json +1 -1
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, { stdio: ['ignore', opts.capture ? 'pipe' : 'ignore', 'pipe'] });
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) => { stdout += chunk.toString(); });
24
- child.stderr?.on('data', (chunk) => { stderr += chunk.toString(); });
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 { /* nothing to clean */ }
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 ?? 'unlisted';
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, visibility };
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "castle-web-cli",
3
- "version": "0.4.137",
3
+ "version": "0.4.138",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "castle-web": "./dist/index.js"