@digitalocean/functions-deployer 5.0.18 → 5.0.20

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/lib/index.js CHANGED
@@ -78,7 +78,6 @@ __export(src_exports, {
78
78
  runtimeForZipMid: () => runtimeForZipMid,
79
79
  switchNamespace: () => switchNamespace,
80
80
  wipeNamespace: () => wipeNamespace,
81
- wipePackage: () => wipePackage,
82
81
  writeSliceResult: () => writeSliceResult,
83
82
  wskRequest: () => wskRequest
84
83
  });
@@ -785,7 +784,7 @@ function locateBuild(buildField, remoteRequested, defaultRemote2, remoteRequired
785
784
  }
786
785
  async function checkBuildingRequirements(todeploy, requestRemote) {
787
786
  var _a;
788
- const checkConflicts = (buildField, remote, local, tag) => {
787
+ const checkConflicts = (remote, local, tag) => {
789
788
  if (remote && local) {
790
789
  throw new Error(
791
790
  `Local and remote building cannot both be required (${tag})`
@@ -797,10 +796,9 @@ async function checkBuildingRequirements(todeploy, requestRemote) {
797
796
  if (pkg.actions) {
798
797
  for (const action of pkg.actions) {
799
798
  checkConflicts(
800
- action.build,
801
799
  action.remoteBuild,
802
800
  action.localBuild,
803
- `action ${action.name}`
801
+ `function ${action.name}`
804
802
  );
805
803
  }
806
804
  }
@@ -819,6 +817,11 @@ async function checkBuildingRequirements(todeploy, requestRemote) {
819
817
  action.remoteBuild,
820
818
  action.localBuild
821
819
  );
820
+ if (action.build === "build.sh" && process.platform === "win32") {
821
+ throw new Error(
822
+ `In function ${action.name}: 'build.sh' won't run on this platform and no 'build.cmd' is provided`
823
+ );
824
+ }
822
825
  needsLocal = needsLocal || !((_a = action.build) == null ? void 0 : _a.startsWith("remote")) && isRealBuild(action.build);
823
826
  }
824
827
  }
@@ -904,10 +907,6 @@ async function validateDeployConfig(arg, noTriggers) {
904
907
  switch (item) {
905
908
  case "slice":
906
909
  continue;
907
- case "cleanNamespace":
908
- if (!(typeof arg[item] === "boolean")) {
909
- return `${item} must be a boolean`;
910
- }
911
910
  break;
912
911
  case "targetNamespace": {
913
912
  if (!(typeof arg[item] === "string") && !isValidOwnership(arg[item])) {
@@ -981,7 +980,7 @@ async function validatePackageSpec(arg, slice, isNimbella, noTriggers) {
981
980
  return actionError;
982
981
  }
983
982
  }
984
- } else if (item === "shared" || item === "clean") {
983
+ } else if (item === "shared") {
985
984
  if (!(typeof arg[item] === "boolean")) {
986
985
  return `'${item}' member of a 'package' must be a boolean`;
987
986
  } else if (isDefault && arg[item]) {
@@ -1033,7 +1032,6 @@ async function validateActionSpec(arg, isNimbella, noTriggers) {
1033
1032
  }
1034
1033
  break;
1035
1034
  case "binary":
1036
- case "clean":
1037
1035
  case "remoteBuild":
1038
1036
  case "localBuild":
1039
1037
  if (!(typeof arg[item] === "boolean")) {
@@ -1098,7 +1096,7 @@ async function validateActionSpec(arg, isNimbella, noTriggers) {
1098
1096
  break;
1099
1097
  }
1100
1098
  default:
1101
- return `Invalid key '${item}' found in 'action' clause in project.yml`;
1099
+ return `Invalid key '${item}' found in 'functions' clause in project.yml`;
1102
1100
  }
1103
1101
  }
1104
1102
  return void 0;
@@ -1287,10 +1285,6 @@ function combineResponses(responses) {
1287
1285
  (prev, curr) => Object.assign(prev, curr.actionVersions),
1288
1286
  {}
1289
1287
  );
1290
- const webHashes = responses.reduce(
1291
- (prev, curr) => Object.assign(prev, curr.webHashes || {}),
1292
- {}
1293
- );
1294
1288
  const namespace = responses.map((r) => r.namespace).reduce((prev, curr) => prev || curr);
1295
1289
  return {
1296
1290
  successes,
@@ -1298,7 +1292,6 @@ function combineResponses(responses) {
1298
1292
  ignored,
1299
1293
  packageVersions,
1300
1294
  actionVersions,
1301
- webHashes,
1302
1295
  namespace
1303
1296
  };
1304
1297
  }
@@ -1599,7 +1592,7 @@ function getBestProjectName(project) {
1599
1592
  async function getDeployerAnnotation(project) {
1600
1593
  const digest = void 0;
1601
1594
  try {
1602
- const git = (0, import_simple_git.default)();
1595
+ const git = (0, import_simple_git.default)(project);
1603
1596
  const root = await git.revparse(["--show-toplevel"]);
1604
1597
  const repo = await git.raw(["config", "--get", "remote.origin.url"]);
1605
1598
  const user = (await git.raw(["config", "--get", "user.email"])).trim();
@@ -1708,7 +1701,6 @@ async function deleteAction(actionName, owClient, credentials) {
1708
1701
  function digestPackage(pkg) {
1709
1702
  const hash = crypto.createHash("sha256");
1710
1703
  digestBoolean(hash, pkg.shared);
1711
- digestBoolean(hash, pkg.clean);
1712
1704
  digestBoolean(hash, pkg.web);
1713
1705
  digestDictionary(hash, pkg.annotations);
1714
1706
  digestDictionary(hash, pkg.parameters);
@@ -1754,7 +1746,6 @@ function digestDictionary(hash, toDigest) {
1754
1746
  }
1755
1747
  function digestAction(action, code) {
1756
1748
  const hash = crypto.createHash("sha256");
1757
- digestBoolean(hash, action.clean);
1758
1749
  digestBoolean(hash, action.binary);
1759
1750
  digestBoolean(hash, action.zipped);
1760
1751
  hash.update(String(action.web));
@@ -1786,8 +1777,8 @@ function writeSliceResult(project, result) {
1786
1777
  }
1787
1778
  function writeProjectStatus(project, results, replace) {
1788
1779
  debug4("writing project status with %O", results);
1789
- const { apihost, namespace, packageVersions, actionVersions, webHashes } = results;
1790
- if (Object.keys(actionVersions).length === 0 && Object.keys(packageVersions).length === 0 && Object.keys(webHashes).length === 0) {
1780
+ const { apihost, namespace, packageVersions, actionVersions } = results;
1781
+ if (Object.keys(actionVersions).length === 0 && Object.keys(packageVersions).length === 0) {
1791
1782
  debug4("there is no meaningful project status to write");
1792
1783
  return "";
1793
1784
  }
@@ -1806,8 +1797,7 @@ function writeProjectStatus(project, results, replace) {
1806
1797
  apihost,
1807
1798
  namespace,
1808
1799
  packageVersions,
1809
- actionVersions,
1810
- webHashes
1800
+ actionVersions
1811
1801
  };
1812
1802
  const oldEntry = versionList.find(
1813
1803
  (entry) => entry.apihost === apihost && entry.namespace === namespace
@@ -1829,7 +1819,6 @@ function mergeVersions(oldEntry, newEntry, replace) {
1829
1819
  } else {
1830
1820
  Object.assign(oldEntry.actionVersions, newEntry.actionVersions);
1831
1821
  Object.assign(oldEntry.packageVersions, newEntry.packageVersions);
1832
- Object.assign(oldEntry.webHashes, newEntry.webHashes);
1833
1822
  }
1834
1823
  }
1835
1824
  function loadVersions(projectPath, namespace, apihost) {
@@ -1846,8 +1835,7 @@ function loadVersions(projectPath, namespace, apihost) {
1846
1835
  namespace,
1847
1836
  apihost,
1848
1837
  packageVersions: {},
1849
- actionVersions: {},
1850
- webHashes: {}
1838
+ actionVersions: {}
1851
1839
  };
1852
1840
  }
1853
1841
  function delay(millis) {
@@ -1957,19 +1945,13 @@ var debug5 = (0, import_debug5.default)("nim:deployer:deploy");
1957
1945
  var seqDebug = (0, import_debug5.default)("nim:deployer:sequences");
1958
1946
  var chunkDebug = (0, import_debug5.default)("nim:deployer:chunk");
1959
1947
  var DEPLOYMENT_CHUNK_SIZE = parseInt(process.env.DEPLOYMENT_CHUNK_SIZE) || 25;
1960
- async function cleanOrLoadVersions(todeploy) {
1948
+ async function maybeLoadVersions(todeploy) {
1961
1949
  if (todeploy.flags.incremental) {
1962
1950
  todeploy.versions = loadVersions(
1963
1951
  todeploy.filePath,
1964
1952
  todeploy.credentials.namespace,
1965
1953
  todeploy.credentials.ow.apihost
1966
1954
  );
1967
- } else {
1968
- if (todeploy.cleanNamespace && todeploy.includer.isIncludingEverything()) {
1969
- await wipe(todeploy.owClient, todeploy.credentials);
1970
- } else {
1971
- await cleanActionsAndPackages(todeploy);
1972
- }
1973
1955
  }
1974
1956
  return Promise.resolve(todeploy);
1975
1957
  }
@@ -2030,72 +2012,14 @@ async function processRemoteResponse(activationId, owClient, context, feedback)
2030
2012
  }
2031
2013
  return outcome;
2032
2014
  }
2033
- function cleanActionsAndPackages(todeploy) {
2034
- if (!todeploy.packages) {
2035
- return Promise.resolve(todeploy);
2036
- }
2037
- const promises = [];
2038
- for (const pkg of todeploy.packages) {
2039
- const defaultPkg = pkg.name === "default";
2040
- if (pkg.clean && !defaultPkg && todeploy.includer.isPackageIncluded(pkg.name, true)) {
2041
- promises.push(
2042
- cleanPackage(
2043
- todeploy.owClient,
2044
- todeploy.credentials,
2045
- pkg.name,
2046
- todeploy.versions
2047
- )
2048
- );
2049
- } else if (pkg.actions) {
2050
- for (const action of pkg.actions) {
2051
- if (action.clean && todeploy.includer.isActionIncluded(pkg.name, action.name) && !action.buildResult) {
2052
- if (todeploy.versions && todeploy.versions.actionVersions) {
2053
- delete todeploy.versions.actionVersions[action.name];
2054
- }
2055
- promises.push(
2056
- deleteAction(
2057
- getActionName(action),
2058
- todeploy.owClient,
2059
- todeploy.credentials
2060
- ).catch(() => void 0)
2061
- );
2062
- }
2063
- }
2064
- }
2065
- }
2066
- return Promise.all(promises).then(() => todeploy);
2067
- }
2068
- async function cleanPackage(client, credentials, name, versions) {
2069
- debug5("Cleaning package %s", name);
2070
- while (true) {
2071
- const pkg = await client.packages.get({ name }).catch(() => void 0);
2072
- if (!pkg) {
2073
- return { name };
2074
- }
2075
- if (!pkg.actions || pkg.actions.length === 0) {
2076
- debug5("No more actions, removing package");
2077
- if (versions && versions.packageVersions) {
2078
- delete versions.packageVersions[name];
2079
- }
2080
- return client.packages.delete({ name });
2081
- }
2082
- for (const action of pkg.actions) {
2083
- debug5("deleting action %s", action.name);
2084
- if (versions && versions.actionVersions) {
2085
- delete versions.actionVersions[action.name];
2086
- }
2087
- await deleteAction(name + "/" + action.name, client, credentials);
2088
- }
2089
- }
2090
- }
2091
- async function deployActionArray(actions, spec, cleanFlag) {
2015
+ async function deployActionArray(actions, spec) {
2092
2016
  let pending = actions;
2093
2017
  const responses = [];
2094
2018
  while (pending.length > 0) {
2095
2019
  const chunk = pending.length > DEPLOYMENT_CHUNK_SIZE ? pending.slice(0, DEPLOYMENT_CHUNK_SIZE) : pending;
2096
2020
  pending = pending.slice(chunk.length);
2097
2021
  const chunkResults = await Promise.all(
2098
- chunk.map((action) => deployAction(action, spec, cleanFlag))
2022
+ chunk.map((action) => deployAction(action, spec))
2099
2023
  ).then(combineResponses);
2100
2024
  responses.push(chunkResults);
2101
2025
  chunkDebug("Deployed chunk of %d actions", chunk.length);
@@ -2106,7 +2030,6 @@ async function onlyDeployPackage(pkg, spec) {
2106
2030
  const {
2107
2031
  parameters: projectParams,
2108
2032
  environment: projectEnv,
2109
- cleanNamespace: namespaceIsClean,
2110
2033
  versions,
2111
2034
  owClient: wsk,
2112
2035
  deployerAnnotation: deployer,
@@ -2125,10 +2048,7 @@ async function onlyDeployPackage(pkg, spec) {
2125
2048
  namespace: void 0
2126
2049
  };
2127
2050
  } else {
2128
- let former;
2129
- if (!pkg.clean && !namespaceIsClean) {
2130
- former = await wsk.packages.get({ name: pkg.name }).catch(() => void 0);
2131
- }
2051
+ const former = await wsk.packages.get({ name: pkg.name }).catch(() => void 0);
2132
2052
  const oldAnnots = former && former.annotations ? makeDict(former.annotations) : {};
2133
2053
  delete oldAnnots.deployerAnnot;
2134
2054
  deployer.digest = digest.substring(0, 8);
@@ -2170,11 +2090,7 @@ async function onlyDeployPackage(pkg, spec) {
2170
2090
  }
2171
2091
  }
2172
2092
  async function deployPackage(pkg, spec, skipPkgDeploy) {
2173
- const {
2174
- parameters: projectParams,
2175
- environment: projectEnv,
2176
- cleanNamespace: namespaceIsClean
2177
- } = spec;
2093
+ const { parameters: projectParams, environment: projectEnv } = spec;
2178
2094
  if (pkg.name === "default" && (pkg.binding || isAtLeastOneNonEmpty([
2179
2095
  projectParams,
2180
2096
  projectEnv,
@@ -2190,14 +2106,10 @@ async function deployPackage(pkg, spec, skipPkgDeploy) {
2190
2106
  );
2191
2107
  }
2192
2108
  if (pkg.name === "default" || skipPkgDeploy || pkg.deployedDuringBuild) {
2193
- return deployActionArray(pkg.actions, spec, namespaceIsClean);
2109
+ return deployActionArray(pkg.actions, spec);
2194
2110
  }
2195
2111
  const pkgResponse = await onlyDeployPackage(pkg, spec);
2196
- const actionPromise = await deployActionArray(
2197
- pkg.actions || [],
2198
- spec,
2199
- pkg.clean || namespaceIsClean
2200
- );
2112
+ const actionPromise = await deployActionArray(pkg.actions || [], spec);
2201
2113
  return combineResponses([actionPromise, pkgResponse]);
2202
2114
  }
2203
2115
  function isAtLeastOneNonEmpty(toCheck) {
@@ -2208,7 +2120,7 @@ function isAtLeastOneNonEmpty(toCheck) {
2208
2120
  }
2209
2121
  return false;
2210
2122
  }
2211
- function deployAction(action, spec, pkgIsClean) {
2123
+ function deployAction(action, spec) {
2212
2124
  const { owClient: wsk, feedback, reader } = spec;
2213
2125
  const context = `action '${getActionName(action)}'`;
2214
2126
  debug5("deploying %s", context);
@@ -2220,13 +2132,7 @@ function deployAction(action, spec, pkgIsClean) {
2220
2132
  }
2221
2133
  if (action.code) {
2222
2134
  debug5("action already has code");
2223
- return deployActionFromCodeOrSequence(
2224
- action,
2225
- spec,
2226
- action.code,
2227
- void 0,
2228
- pkgIsClean
2229
- );
2135
+ return deployActionFromCodeOrSequence(action, spec, action.code, void 0);
2230
2136
  }
2231
2137
  if (action.sequence) {
2232
2138
  const error = checkForLegalSequence(action);
@@ -2246,13 +2152,7 @@ function deployAction(action, spec, pkgIsClean) {
2246
2152
  const code = action.binary ? data.toString("base64") : String(data);
2247
2153
  return code;
2248
2154
  }).then(
2249
- (code) => deployActionFromCodeOrSequence(
2250
- action,
2251
- spec,
2252
- code,
2253
- void 0,
2254
- pkgIsClean
2255
- )
2155
+ (code) => deployActionFromCodeOrSequence(action, spec, code, void 0)
2256
2156
  ).catch((err) => Promise.resolve(wrapError(err, context)));
2257
2157
  } else {
2258
2158
  return Promise.resolve(
@@ -2362,24 +2262,11 @@ async function deploySequences(todeploy) {
2362
2262
  );
2363
2263
  const exec = { kind: "sequence", components };
2364
2264
  result.push(
2365
- await deployActionFromCodeOrSequence(
2366
- seq,
2367
- todeploy,
2368
- void 0,
2369
- exec,
2370
- isCleanPkg(todeploy, seq.package)
2371
- )
2265
+ await deployActionFromCodeOrSequence(seq, todeploy, void 0, exec)
2372
2266
  );
2373
2267
  }
2374
2268
  return result;
2375
2269
  }
2376
- function isCleanPkg(spec, pkgName) {
2377
- if (spec.cleanNamespace) {
2378
- return true;
2379
- }
2380
- const pkg = (spec.packages || []).find((pkg2) => pkg2.name === pkgName);
2381
- return !!(pkg == null ? void 0 : pkg.clean);
2382
- }
2383
2270
  function fqnFromActionSpec(spec, namespace) {
2384
2271
  let name = spec.name;
2385
2272
  if (spec.package && spec.package !== "default") {
@@ -2431,7 +2318,7 @@ function calculateActionExec(action, code) {
2431
2318
  }
2432
2319
  return { code, binary: action.binary, kind: action.runtime, main: main2 };
2433
2320
  }
2434
- async function deployActionFromCodeOrSequence(action, spec, code, sequence, pkgIsClean) {
2321
+ async function deployActionFromCodeOrSequence(action, spec, code, sequence) {
2435
2322
  const name = getActionName(action);
2436
2323
  const { versions, flags, deployerAnnotation, owClient: wsk } = spec;
2437
2324
  const deployerAnnot = Object.assign({}, deployerAnnotation);
@@ -2480,11 +2367,8 @@ async function deployActionFromCodeOrSequence(action, spec, code, sequence, pkgI
2480
2367
  } else {
2481
2368
  annotations["require-whisk-auth"] = false;
2482
2369
  }
2483
- let former;
2484
- if (!action.clean && !pkgIsClean) {
2485
- const options = { name, code: false };
2486
- former = await wsk.actions.get(options).catch(() => void 0);
2487
- }
2370
+ const options = { name, code: false };
2371
+ const former = await wsk.actions.get(options).catch(() => void 0);
2488
2372
  const oldAnnots = former && former.annotations ? makeDict(former.annotations) : {};
2489
2373
  const annotDict = Object.assign({}, oldAnnots, annotations);
2490
2374
  const params = encodeParameters(action.parameters, action.environment);
@@ -2539,7 +2423,7 @@ var path4 = __toESM(require("path"));
2539
2423
  var fs4 = __toESM(require("fs"));
2540
2424
  var yaml2 = __toESM(require("js-yaml"));
2541
2425
  var import_ignore = __toESM(require("ignore"));
2542
- var import_axios3 = __toESM(require("axios"));
2426
+ var import_axios4 = __toESM(require("axios"));
2543
2427
  var import_archiver = __toESM(require("archiver"));
2544
2428
  var import_touch = __toESM(require("touch"));
2545
2429
  var import_debug7 = __toESM(require("debug"));
@@ -2551,23 +2435,15 @@ var fs3 = __toESM(require("fs"));
2551
2435
  var import_debug6 = __toESM(require("debug"));
2552
2436
  var import_adm_zip = __toESM(require("adm-zip"));
2553
2437
  var rimraf = __toESM(require("rimraf"));
2554
- var import_client_s3 = require("@aws-sdk/client-s3");
2555
2438
  var import_memory_streams = require("memory-streams");
2439
+ var import_axios3 = __toESM(require("axios"));
2440
+ var import_openwhisk = __toESM(require("openwhisk"));
2556
2441
  var debug6 = (0, import_debug6.default)("nim:deployer:slice-reader");
2557
2442
  var TEMP = process.platform === "win32" ? process.env.TEMP : "/tmp";
2558
- var bucket = process.env.BUILDER_BUCKET_NAME;
2559
- var endpoint = process.env.S3_ENDPOINT;
2560
2443
  var MAX_SLICE_UPLOAD_SIZE = parseInt(process.env.MAX_SLICE_UPLOAD_SIZE) || 64 * 1024 * 1024;
2561
- var s3Client;
2562
2444
  function cacheArea() {
2563
2445
  return path3.join(TEMP, "slices");
2564
2446
  }
2565
- function getS3Client() {
2566
- if (!s3Client) {
2567
- s3Client = new import_client_s3.S3Client({ endpoint, region: "us-east-1" });
2568
- }
2569
- return s3Client;
2570
- }
2571
2447
  function pipe(input, output) {
2572
2448
  const toWait = new Promise(function(resolve5) {
2573
2449
  output.on("close", () => {
@@ -2581,20 +2457,49 @@ function pipe(input, output) {
2581
2457
  return toWait;
2582
2458
  }
2583
2459
  async function fetchSlice(sliceName) {
2460
+ var _a, _b;
2461
+ const GET_DOWNLOAD_URL = `/${BUILDER_NAMESPACE}/builder/getDownloadUrl`;
2462
+ const credentials = getCredentialsFromEnvironment();
2463
+ const owClient = (0, import_openwhisk.default)({
2464
+ apihost: credentials.ow.apihost,
2465
+ api_key: credentials.ow.api_key,
2466
+ namespace: credentials.namespace
2467
+ });
2468
+ const invoked = await owClient.actions.invoke({
2469
+ name: GET_DOWNLOAD_URL,
2470
+ params: {
2471
+ name: sliceName
2472
+ }
2473
+ });
2474
+ const activation = await waitForActivation(
2475
+ invoked.activationId,
2476
+ owClient,
2477
+ () => {
2478
+ debug6("fetching build assets ...");
2479
+ },
2480
+ 60
2481
+ );
2482
+ if (!activation) {
2483
+ throw new Error(`Timed out fetching assets url for '${sliceName}'`);
2484
+ }
2485
+ const activationResponse = activation.response;
2486
+ const downloadUrl = (_b = (_a = activation.response) == null ? void 0 : _a.result) == null ? void 0 : _b.url;
2487
+ if (!activationResponse || !(activationResponse == null ? void 0 : activationResponse.success) || !downloadUrl) {
2488
+ throw new Error(`Failed to fetch assets url for '${sliceName}'`);
2489
+ }
2490
+ const response = await import_axios3.default.get(downloadUrl, {
2491
+ responseType: "stream"
2492
+ });
2584
2493
  const cache = path3.join(cacheArea(), sliceName);
2585
2494
  if (fs3.existsSync(cache)) {
2586
2495
  rimraf.sync(cache);
2587
2496
  }
2588
2497
  debug6("Making cache directory: %s", cache);
2589
2498
  fs3.mkdirSync(cache, { recursive: true });
2590
- const s3 = getS3Client();
2591
- const cmd = new import_client_s3.GetObjectCommand({ Bucket: bucket, Key: sliceName });
2592
- const result = await s3.send(cmd);
2593
- const content = result.Body;
2594
2499
  const destination = new import_memory_streams.WritableStream({
2595
2500
  highWaterMark: MAX_SLICE_UPLOAD_SIZE
2596
2501
  });
2597
- await pipe(content, destination);
2502
+ await pipe(response.data, destination);
2598
2503
  const data = destination.toBuffer();
2599
2504
  const zip = new import_adm_zip.default(data);
2600
2505
  debug6("zip file has %d entries", zip.getEntries().length);
@@ -2611,14 +2516,30 @@ async function fetchSlice(sliceName) {
2611
2516
  return cache;
2612
2517
  }
2613
2518
  async function deleteSlice(project) {
2519
+ const DELETE_ASSETS_URL = `/${BUILDER_NAMESPACE}/builder/deleteBuildAssets`;
2614
2520
  const sliceName = path3.relative(cacheArea(), project.filePath);
2615
- const s3 = getS3Client();
2616
- const cmd = new import_client_s3.DeleteObjectCommand({ Bucket: bucket, Key: sliceName });
2617
- await s3.send(cmd);
2521
+ const credentials = getCredentialsFromEnvironment();
2522
+ const owClient = (0, import_openwhisk.default)({
2523
+ apihost: credentials.ow.apihost,
2524
+ api_key: credentials.ow.api_key,
2525
+ namespace: credentials.namespace
2526
+ });
2527
+ const invoked = await owClient.actions.invoke({
2528
+ name: DELETE_ASSETS_URL,
2529
+ params: {
2530
+ name: sliceName
2531
+ }
2532
+ });
2533
+ await waitForActivation(
2534
+ invoked.activationId,
2535
+ owClient,
2536
+ () => debug6("removing build assets ..."),
2537
+ 60
2538
+ );
2618
2539
  }
2619
2540
 
2620
2541
  // src/finder-builder.ts
2621
- var openwhisk = require("openwhisk");
2542
+ var openwhisk2 = require("openwhisk");
2622
2543
  var debug7 = (0, import_debug7.default)("nim:deployer:finder-builder");
2623
2544
  var zipDebug = (0, import_debug7.default)("nim:deployer:zip");
2624
2545
  var ZIP_TARGET = "__deployer__.zip";
@@ -2631,7 +2552,7 @@ set -e
2631
2552
  `;
2632
2553
  function getBuildForAction(filepath, reader) {
2633
2554
  return readDirectory(filepath, reader).then(
2634
- (items) => findSpecialFile(items, filepath, true, false)
2555
+ (items) => findSpecialFile(items, filepath, true)
2635
2556
  );
2636
2557
  }
2637
2558
  async function buildAllActions(spec) {
@@ -2771,10 +2692,10 @@ function buildAction(action, spec) {
2771
2692
  throw new Error("Unknown build type in ActionSpec: " + action.build);
2772
2693
  }
2773
2694
  }
2774
- async function processInclude(includesPath, dirPath, reader, web) {
2695
+ async function processInclude(includesPath, dirPath, reader) {
2775
2696
  debug7("processing includes from '%s'", includesPath);
2776
2697
  const items = await readFileAsList(includesPath, reader);
2777
- const errMsg = checkIncludeItems(items, web);
2698
+ const errMsg = checkIncludeItems(items);
2778
2699
  if (errMsg) {
2779
2700
  return Promise.reject(new Error(errMsg));
2780
2701
  }
@@ -2838,24 +2759,22 @@ async function identifyActionFiles(action, incremental, verboseZip, reader, feed
2838
2759
  includesPath = path4.join(action.file, ".source");
2839
2760
  }
2840
2761
  if (await reader.isExistingFile(includesPath)) {
2841
- return processInclude(includesPath, action.file, reader, false).then(
2842
- (pairs) => {
2843
- if (pairs.length === 0) {
2844
- return Promise.reject(new Error(includesPath + " is empty"));
2845
- } else if (pairs.length > 1) {
2846
- return autozipBuilder(
2847
- pairs,
2848
- action,
2849
- incremental,
2850
- verboseZip,
2851
- reader,
2852
- feedback
2853
- );
2854
- } else {
2855
- return singleFileBuilder(action, pairs[0][0]);
2856
- }
2762
+ return processInclude(includesPath, action.file, reader).then((pairs) => {
2763
+ if (pairs.length === 0) {
2764
+ return Promise.reject(new Error(includesPath + " is empty"));
2765
+ } else if (pairs.length > 1) {
2766
+ return autozipBuilder(
2767
+ pairs,
2768
+ action,
2769
+ incremental,
2770
+ verboseZip,
2771
+ reader,
2772
+ feedback
2773
+ );
2774
+ } else {
2775
+ return singleFileBuilder(action, pairs[0][0]);
2857
2776
  }
2858
- );
2777
+ });
2859
2778
  }
2860
2779
  return getIgnores(action.file, reader).then((ignore2) => {
2861
2780
  return promiseFilesAndFilterFiles(action.file, reader).then(
@@ -2901,12 +2820,12 @@ function readFileAsList(file, reader) {
2901
2820
  (data) => String(data).split("\n").filter((line) => line && line.trim().length > 0).map((line) => line.trim())
2902
2821
  );
2903
2822
  }
2904
- function getBuildForLibOrWeb(filepath, reader, lib) {
2823
+ function getBuildForLib(filepath, reader) {
2905
2824
  if (!filepath) {
2906
2825
  return Promise.resolve(void 0);
2907
2826
  }
2908
2827
  return readDirectory(filepath, reader).then(
2909
- (items) => findSpecialFile(items, filepath, false, lib)
2828
+ (items) => findSpecialFile(items, filepath, false)
2910
2829
  );
2911
2830
  }
2912
2831
  async function maybeBuildLib(spec) {
@@ -2997,8 +2916,8 @@ function checkBuiltLocally(reader, localPath) {
2997
2916
  }
2998
2917
  debug7("checkBuiltLocally passed");
2999
2918
  }
3000
- function checkIncludeItems(items, web) {
3001
- const legalDots = web ? "../lib" : "../../../lib";
2919
+ function checkIncludeItems(items) {
2920
+ const legalDots = "../../../lib";
3002
2921
  for (const item of items) {
3003
2922
  if (!item || item.length === 0) {
3004
2923
  continue;
@@ -3012,7 +2931,7 @@ function checkIncludeItems(items, web) {
3012
2931
  }
3013
2932
  return "";
3014
2933
  }
3015
- async function checkRemoteBuildPreReqs(filepath, project, web) {
2934
+ async function checkRemoteBuildPreReqs(filepath, project) {
3016
2935
  debug7(`checking remote build pre-reqs for '${filepath}'`);
3017
2936
  const reader = project.reader;
3018
2937
  if ((await reader.getPathKind(filepath)).isDirectory) {
@@ -3021,7 +2940,7 @@ async function checkRemoteBuildPreReqs(filepath, project, web) {
3021
2940
  debug7(`found an .include file for '${filepath}'`);
3022
2941
  const items = await readFileAsList(include, reader);
3023
2942
  debug7(`read ${items.length} .include items for '${filepath}'`);
3024
- const msg = checkIncludeItems(items, web);
2943
+ const msg = checkIncludeItems(items);
3025
2944
  if (msg) {
3026
2945
  throw new Error(msg);
3027
2946
  }
@@ -3029,7 +2948,7 @@ async function checkRemoteBuildPreReqs(filepath, project, web) {
3029
2948
  }
3030
2949
  }
3031
2950
  async function doRemoteActionBuild(action, project) {
3032
- await checkRemoteBuildPreReqs(action.file, project, false);
2951
+ await checkRemoteBuildPreReqs(action.file, project);
3033
2952
  const { zip, output, outputPromise } = makeProjectSliceZip(action.file);
3034
2953
  const pkgName = path4.basename(path4.dirname(action.file));
3035
2954
  const actionName = pkgName === "default" ? action.name : path4.join(pkgName, action.name);
@@ -3142,7 +3061,6 @@ function makeConfigFromActionSpec(action, spec, pkgName) {
3142
3061
  debug7("converting action spec to sliced project.yml: %O", action);
3143
3062
  const {
3144
3063
  targetNamespace,
3145
- cleanNamespace,
3146
3064
  parameters,
3147
3065
  environment: globalEnv,
3148
3066
  credentials,
@@ -3162,12 +3080,10 @@ function makeConfigFromActionSpec(action, spec, pkgName) {
3162
3080
  webSecure,
3163
3081
  annotations,
3164
3082
  environment,
3165
- limits,
3166
- clean
3083
+ limits
3167
3084
  } = action;
3168
3085
  const newSpec = {
3169
3086
  targetNamespace,
3170
- cleanNamespace,
3171
3087
  parameters,
3172
3088
  environment: globalEnv,
3173
3089
  credentials,
@@ -3187,8 +3103,7 @@ function makeConfigFromActionSpec(action, spec, pkgName) {
3187
3103
  annotations,
3188
3104
  parameters: action.parameters,
3189
3105
  environment,
3190
- limits,
3191
- clean
3106
+ limits
3192
3107
  };
3193
3108
  removeUndefined(newSpec);
3194
3109
  removeUndefined(newAction);
@@ -3251,9 +3166,6 @@ function makeProjectSliceZip(context) {
3251
3166
  return { output, zip, outputPromise };
3252
3167
  }
3253
3168
  function computeTag(action) {
3254
- if (!action) {
3255
- return "web";
3256
- }
3257
3169
  if (action.package) {
3258
3170
  return `${action.package}_${action.name}`;
3259
3171
  }
@@ -3309,15 +3221,15 @@ async function invokeRemoteBuilder(zipped, owClient, feedback, action, encryptio
3309
3221
  maxBodyLength: MAX_SLICE_UPLOAD_SIZE,
3310
3222
  maxContentLength: MAX_SLICE_UPLOAD_SIZE
3311
3223
  };
3312
- const result = await import_axios3.default.put(url, zipped, axiosConfig);
3224
+ const result = await import_axios4.default.put(url, zipped, axiosConfig);
3313
3225
  if (result.status !== 200) {
3314
3226
  throw new Error(
3315
3227
  `Bad response [$result.status}] when uploading '${sliceName}' for remote build`
3316
3228
  );
3317
3229
  }
3318
3230
  debug7("axios put of url was successful");
3319
- const kind = action ? action.runtime : "nodejs:default";
3320
- const activityName = action ? `action '${getActionName(action)}'` : "web content";
3231
+ const kind = action.runtime;
3232
+ const activityName = `function '${getActionName(action)}'`;
3321
3233
  const runtime = (await canonicalRuntime(kind)).replace(":", "_");
3322
3234
  const buildActionName = `${BUILDER_ACTION_STEM}${runtime}`;
3323
3235
  debug7(
@@ -3349,7 +3261,7 @@ async function invokeRemoteBuilder(zipped, owClient, feedback, action, encryptio
3349
3261
  function readDirectory(filepath, reader) {
3350
3262
  return reader.readdir(filepath).then(filterFiles);
3351
3263
  }
3352
- function findSpecialFile(items, filepath, isAction, isLib) {
3264
+ function findSpecialFile(items, filepath, isAction) {
3353
3265
  const files = items.filter((item) => !item.isDirectory);
3354
3266
  let buildDotSh = false;
3355
3267
  let buildDotCmd = false;
@@ -3375,29 +3287,21 @@ function findSpecialFile(items, filepath, isAction, isLib) {
3375
3287
  );
3376
3288
  } else if (isAction && (files.length === 0 || ignore2 && files.length === 1)) {
3377
3289
  throw new Error(`Action directory ${filepath} has no files`);
3378
- } else if (isLib && (include || ignore2)) {
3290
+ } else if (!isAction && (include || ignore2)) {
3379
3291
  throw new Error(
3380
3292
  `'.include' and '.ignore' are not supported in the 'lib' directory`
3381
3293
  );
3382
3294
  }
3383
- if (process.platform === "win32") {
3384
- if (buildDotSh && !buildDotCmd) {
3385
- throw new Error(
3386
- `In ${filepath}: 'build.sh' won't run on this platform and no 'build.cmd' is provided`
3387
- );
3388
- }
3389
- if (buildDotCmd) {
3390
- return "build.cmd";
3391
- }
3392
- } else {
3393
- if (!buildDotSh && buildDotCmd) {
3394
- throw new Error(
3395
- `In ${filepath}: 'build.cmd' won't run on this platform and no 'build.sh' is provided`
3396
- );
3397
- }
3398
- if (buildDotSh) {
3399
- return "build.sh";
3400
- }
3295
+ if (buildDotCmd && process.platform === "win32") {
3296
+ return "build.cmd";
3297
+ }
3298
+ if (buildDotCmd && !buildDotSh) {
3299
+ throw new Error(
3300
+ `In ${filepath}: 'build.cmd' won't run on this platform and no 'build.sh' is provided`
3301
+ );
3302
+ }
3303
+ if (buildDotSh) {
3304
+ return "build.sh";
3401
3305
  }
3402
3306
  return npm ? "package.json" : include ? ".include" : "identify";
3403
3307
  }
@@ -3708,7 +3612,7 @@ var import_debug9 = __toESM(require("debug"));
3708
3612
  // src/file-reader.ts
3709
3613
  var fs5 = __toESM(require("fs"));
3710
3614
  var Path = __toESM(require("path"));
3711
- var import_util4 = require("util");
3615
+ var import_util5 = require("util");
3712
3616
  var import_debug8 = __toESM(require("debug"));
3713
3617
  var debug8 = (0, import_debug8.default)("nim:deployer:file-reader");
3714
3618
  var fs_readdir;
@@ -3718,11 +3622,11 @@ var fs_realpath;
3718
3622
  var fs_readlink;
3719
3623
  function makeFileReader(basepath) {
3720
3624
  debug8("making file reader on basepath '%s'", basepath);
3721
- fs_readdir = (0, import_util4.promisify)(fs5.readdir);
3722
- fs_readfile = (0, import_util4.promisify)(fs5.readFile);
3723
- fs_lstat = (0, import_util4.promisify)(fs5.lstat);
3724
- fs_realpath = (0, import_util4.promisify)(fs5.realpath);
3725
- fs_readlink = (0, import_util4.promisify)(fs5.readlink);
3625
+ fs_readdir = (0, import_util5.promisify)(fs5.readdir);
3626
+ fs_readfile = (0, import_util5.promisify)(fs5.readFile);
3627
+ fs_lstat = (0, import_util5.promisify)(fs5.lstat);
3628
+ fs_realpath = (0, import_util5.promisify)(fs5.realpath);
3629
+ fs_readlink = (0, import_util5.promisify)(fs5.readlink);
3726
3630
  return new FileProjectReader(basepath);
3727
3631
  }
3728
3632
  var FileProjectReader = class {
@@ -3927,7 +3831,7 @@ async function buildStructureParts(topLevel) {
3927
3831
  includer,
3928
3832
  reader
3929
3833
  );
3930
- configPart.libBuild = await getBuildForLibOrWeb(lib, reader, true);
3834
+ configPart.libBuild = await getBuildForLib(lib, reader);
3931
3835
  return [actionsPart, configPart];
3932
3836
  }
3933
3837
  function assembleInitialStructure(parts) {
@@ -4030,7 +3934,7 @@ function buildActionsPart(pkgsdir, displayPath, includer, reader) {
4030
3934
  reader
4031
3935
  ).then((values) => {
4032
3936
  const [strays, pkgs] = values;
4033
- return { web: [], packages: pkgs, strays };
3937
+ return { packages: pkgs, strays };
4034
3938
  });
4035
3939
  }
4036
3940
  }
@@ -4249,7 +4153,7 @@ var IncluderImpl = class {
4249
4153
 
4250
4154
  // src/api.ts
4251
4155
  var import_debug11 = __toESM(require("debug"));
4252
- var openwhisk2 = require("openwhisk");
4156
+ var openwhisk3 = require("openwhisk");
4253
4157
  var debug11 = (0, import_debug11.default)("nim:deployer:api");
4254
4158
  function initializeAPI(userAgent) {
4255
4159
  const result = {};
@@ -4306,7 +4210,7 @@ function readAndPrepare(path7, credentials, flags, feedback) {
4306
4210
  }
4307
4211
  function deploy(todeploy) {
4308
4212
  debug11("Starting deploy");
4309
- return cleanOrLoadVersions(todeploy).then(doDeploy).then((results) => {
4213
+ return maybeLoadVersions(todeploy).then(doDeploy).then((results) => {
4310
4214
  const statusDir = writeProjectStatus(
4311
4215
  todeploy.filePath,
4312
4216
  results,
@@ -4349,33 +4253,11 @@ async function readProject(projectPath, envPath, buildEnvPath, includer, request
4349
4253
  return ans;
4350
4254
  }
4351
4255
  debug11("evaluating the just-read project: %O", ans);
4352
- let needsLocalBuilds;
4353
4256
  try {
4354
- needsLocalBuilds = await checkBuildingRequirements(ans, requestRemote);
4355
- debug11("needsLocalBuilds=%s", needsLocalBuilds);
4257
+ await checkBuildingRequirements(ans, requestRemote);
4356
4258
  } catch (err) {
4357
4259
  return errorStructure(err);
4358
4260
  }
4359
- if (needsLocalBuilds && ans.reader.getFSLocation() === null) {
4360
- debug11(
4361
- "project '%s' will be re-read and cached because it is covered by a non-file-system reader and needs local building",
4362
- projectPath
4363
- );
4364
- try {
4365
- const topLevel = await readTopLevel(
4366
- projectPath,
4367
- envPath,
4368
- buildEnvPath,
4369
- includer,
4370
- feedback,
4371
- noTriggers
4372
- );
4373
- const parts = await buildStructureParts(topLevel);
4374
- ans = assembleInitialStructure(parts);
4375
- } catch (err) {
4376
- return errorStructure(err);
4377
- }
4378
- }
4379
4261
  return ans;
4380
4262
  }
4381
4263
  async function buildProject(project) {
@@ -4455,7 +4337,7 @@ async function prepareToDeploy(inputSpec, credentials, flags) {
4455
4337
  inputSpec.flags = flags;
4456
4338
  debug11("Options merged");
4457
4339
  debug11("Auth sufficiency established");
4458
- inputSpec.owClient = openwhisk2(wskoptions);
4340
+ inputSpec.owClient = openwhisk3(wskoptions);
4459
4341
  if (!credentials.namespace) {
4460
4342
  credentials.namespace = await getTargetNamespace(inputSpec.owClient);
4461
4343
  } else {
@@ -4476,21 +4358,10 @@ async function wipeNamespace(credentials) {
4476
4358
  apihost: credentials.ow.apihost,
4477
4359
  api_key: credentials.ow.api_key
4478
4360
  };
4479
- const client = openwhisk2(init);
4361
+ const client = openwhisk3(init);
4480
4362
  debug11("Client opened");
4481
4363
  return wipe(client, credentials);
4482
4364
  }
4483
- async function wipePackage(name, host, auth, credentials) {
4484
- debug11(
4485
- "wipePackage invoked with name='%s', host='%s', auth='%s",
4486
- name,
4487
- host,
4488
- auth
4489
- );
4490
- const init = { apihost: host, api_key: auth };
4491
- const client = openwhisk2(init);
4492
- return cleanPackage(client, credentials, name, void 0);
4493
- }
4494
4365
 
4495
4366
  // src/watch.ts
4496
4367
  var fs7 = __toESM(require("fs"));
@@ -4570,7 +4441,7 @@ var import_http = require("http");
4570
4441
  var import_debug12 = __toESM(require("debug"));
4571
4442
 
4572
4443
  // src/version.ts
4573
- var version = "5.0.18";
4444
+ var version = "5.0.20";
4574
4445
 
4575
4446
  // src/main.ts
4576
4447
  var verboseError = (0, import_debug12.default)("nim:error");
@@ -4588,7 +4459,7 @@ var DefaultLogger = class {
4588
4459
  msg = improveErrorMsg(msg, err);
4589
4460
  verboseError("%O", err);
4590
4461
  const bang = process.platform === "win32" ? "\xBB" : "\u203A";
4591
- console.log(bang + " Error: " + msg);
4462
+ console.error(bang + " Error: " + msg);
4592
4463
  }
4593
4464
  exit(code) {
4594
4465
  process.exit(code);
@@ -5041,7 +4912,6 @@ function improveErrorMsg(msg, err) {
5041
4912
  runtimeForZipMid,
5042
4913
  switchNamespace,
5043
4914
  wipeNamespace,
5044
- wipePackage,
5045
4915
  writeSliceResult,
5046
4916
  wskRequest
5047
4917
  });