@kirkelliott/zap 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.
Files changed (2) hide show
  1. package/dist/init.js +11 -5
  2. package/package.json +1 -1
package/dist/init.js CHANGED
@@ -8,6 +8,8 @@ const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
8
8
  const node_child_process_1 = require("node:child_process");
9
9
  const node_crypto_1 = require("node:crypto");
10
10
  const node_fs_1 = require("node:fs");
11
+ const node_path_1 = require("node:path");
12
+ const node_os_1 = require("node:os");
11
13
  const ROLE = 'zap-runtime-role';
12
14
  const FUNCTION = 'zap-runtime';
13
15
  const TABLE = 'zap-kv';
@@ -36,10 +38,14 @@ async function init(region) {
36
38
  config = JSON.parse((0, node_fs_1.readFileSync)('.zaprc', 'utf8'));
37
39
  }
38
40
  catch { }
39
- // Build
40
- let done = step('building runtime');
41
- (0, node_child_process_1.execSync)('npx tsc', { stdio: 'pipe' });
42
- (0, node_child_process_1.execSync)('zip -j dist/runtime.zip dist/*.js', { stdio: 'pipe' });
41
+ // Build — compile from source if running in the repo, otherwise use pre-built dist
42
+ let done = step('packaging runtime');
43
+ const distDir = (0, node_path_1.join)(__dirname, '.');
44
+ const srcDir = (0, node_path_1.join)(__dirname, '..', 'src');
45
+ if ((0, node_fs_1.existsSync)(srcDir))
46
+ (0, node_child_process_1.execSync)('npx tsc', { stdio: 'pipe' });
47
+ const zipPath = (0, node_path_1.join)((0, node_os_1.tmpdir)(), 'zap-runtime.zip');
48
+ (0, node_child_process_1.execSync)(`zip -j ${zipPath} ${distDir}/*.js`, { stdio: 'pipe' });
43
49
  done();
44
50
  // Bucket
45
51
  const bucket = config.bucket ?? `zap-${(0, node_crypto_1.randomBytes)(4).toString('hex')}`;
@@ -98,7 +104,7 @@ async function init(region) {
98
104
  done();
99
105
  // Lambda
100
106
  done = step('deploying lambda');
101
- const zip = (0, node_fs_1.readFileSync)('dist/runtime.zip');
107
+ const zip = (0, node_fs_1.readFileSync)(zipPath);
102
108
  const env = { ZAP_BUCKET: bucket, ZAP_TABLE: TABLE };
103
109
  let functionArn;
104
110
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kirkelliott/zap",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Drop a .zap file in S3. It becomes an API endpoint.",
5
5
  "main": "dist/handler.js",
6
6
  "bin": {