@pitcher/cli-scripts 3.0.0 → 3.0.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.
@@ -36,7 +36,15 @@ export async function runDevSync(opts, deps = {}) {
36
36
  const appJson = readAppJson(distPath);
37
37
  const client = deps.client ?? makeClient(target.baseUrl, target.source);
38
38
  log(`Syncing ${appJson.name} from ${distPath}...`, { quiet: opts.quiet });
39
- const zip = await zipDirectoryToBuffer(distPath);
39
+ // node_modules is never part of an app, and zipping it means uploading tens of thousands of files.
40
+ let hasNodeModules = false;
41
+ const zip = await zipDirectoryToBuffer(distPath, (name) => {
42
+ const isInNodeModules = name.split(/[\\/]/).includes('node_modules');
43
+ hasNodeModules || (hasNodeModules = isInNodeModules);
44
+ return isInNodeModules;
45
+ });
46
+ if (hasNodeModules)
47
+ log('Left node_modules out of the zip', { quiet: opts.quiet });
40
48
  log(`Zip created: ${(zip.length / 1024).toFixed(2)} KB`, { quiet: opts.quiet });
41
49
  const form = new FormData();
42
50
  form.append('app_name', appJson.name);
@@ -1,2 +1,3 @@
1
- export declare function zipDirectoryToBuffer(dir: string): Promise<Buffer>;
1
+ /** `skip` gets each entry's path relative to `dir` and returns true to leave it out. */
2
+ export declare function zipDirectoryToBuffer(dir: string, skip?: (name: string) => boolean): Promise<Buffer>;
2
3
  export declare function zipDirectoryToFile(dir: string, outPath: string): Promise<number>;
@@ -1,13 +1,14 @@
1
1
  import { ZipArchive } from 'archiver';
2
2
  import fs from 'fs';
3
- export async function zipDirectoryToBuffer(dir) {
3
+ /** `skip` gets each entry's path relative to `dir` and returns true to leave it out. */
4
+ export async function zipDirectoryToBuffer(dir, skip) {
4
5
  return new Promise((resolve, reject) => {
5
6
  const chunks = [];
6
7
  const archive = new ZipArchive({ zlib: { level: 9 } });
7
8
  archive.on('data', (chunk) => chunks.push(chunk));
8
9
  archive.on('end', () => resolve(Buffer.concat(chunks)));
9
10
  archive.on('error', reject);
10
- archive.directory(dir, false);
11
+ archive.directory(dir, false, (entry) => (skip?.(entry.name) ? false : entry));
11
12
  archive.finalize();
12
13
  });
13
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pitcher/cli-scripts",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "The Pitcher CLI for various tasks in its ecosystem.",
5
5
  "author": "Pitcher AG",
6
6
  "license": "MIT",