@digitalocean/functions-deployer 5.0.18 → 5.0.19
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/api.d.ts +0 -2
- package/lib/deploy-struct.d.ts +1 -10
- package/lib/deploy.d.ts +2 -3
- package/lib/finder-builder.d.ts +2 -2
- package/lib/index.d.ts +1 -1
- package/lib/index.js +75 -242
- package/lib/index.js.map +3 -3
- package/lib/version.d.ts +1 -1
- package/package.json +1 -1
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 = (
|
|
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
|
-
`
|
|
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"
|
|
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 '
|
|
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
|
|
1790
|
-
if (Object.keys(actionVersions).length === 0 && Object.keys(packageVersions).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
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
2484
|
-
|
|
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);
|
|
@@ -2631,7 +2515,7 @@ set -e
|
|
|
2631
2515
|
`;
|
|
2632
2516
|
function getBuildForAction(filepath, reader) {
|
|
2633
2517
|
return readDirectory(filepath, reader).then(
|
|
2634
|
-
(items) => findSpecialFile(items, filepath, true
|
|
2518
|
+
(items) => findSpecialFile(items, filepath, true)
|
|
2635
2519
|
);
|
|
2636
2520
|
}
|
|
2637
2521
|
async function buildAllActions(spec) {
|
|
@@ -2771,10 +2655,10 @@ function buildAction(action, spec) {
|
|
|
2771
2655
|
throw new Error("Unknown build type in ActionSpec: " + action.build);
|
|
2772
2656
|
}
|
|
2773
2657
|
}
|
|
2774
|
-
async function processInclude(includesPath, dirPath, reader
|
|
2658
|
+
async function processInclude(includesPath, dirPath, reader) {
|
|
2775
2659
|
debug7("processing includes from '%s'", includesPath);
|
|
2776
2660
|
const items = await readFileAsList(includesPath, reader);
|
|
2777
|
-
const errMsg = checkIncludeItems(items
|
|
2661
|
+
const errMsg = checkIncludeItems(items);
|
|
2778
2662
|
if (errMsg) {
|
|
2779
2663
|
return Promise.reject(new Error(errMsg));
|
|
2780
2664
|
}
|
|
@@ -2838,24 +2722,22 @@ async function identifyActionFiles(action, incremental, verboseZip, reader, feed
|
|
|
2838
2722
|
includesPath = path4.join(action.file, ".source");
|
|
2839
2723
|
}
|
|
2840
2724
|
if (await reader.isExistingFile(includesPath)) {
|
|
2841
|
-
return processInclude(includesPath, action.file, reader
|
|
2842
|
-
(pairs)
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
return singleFileBuilder(action, pairs[0][0]);
|
|
2856
|
-
}
|
|
2725
|
+
return processInclude(includesPath, action.file, reader).then((pairs) => {
|
|
2726
|
+
if (pairs.length === 0) {
|
|
2727
|
+
return Promise.reject(new Error(includesPath + " is empty"));
|
|
2728
|
+
} else if (pairs.length > 1) {
|
|
2729
|
+
return autozipBuilder(
|
|
2730
|
+
pairs,
|
|
2731
|
+
action,
|
|
2732
|
+
incremental,
|
|
2733
|
+
verboseZip,
|
|
2734
|
+
reader,
|
|
2735
|
+
feedback
|
|
2736
|
+
);
|
|
2737
|
+
} else {
|
|
2738
|
+
return singleFileBuilder(action, pairs[0][0]);
|
|
2857
2739
|
}
|
|
2858
|
-
);
|
|
2740
|
+
});
|
|
2859
2741
|
}
|
|
2860
2742
|
return getIgnores(action.file, reader).then((ignore2) => {
|
|
2861
2743
|
return promiseFilesAndFilterFiles(action.file, reader).then(
|
|
@@ -2901,12 +2783,12 @@ function readFileAsList(file, reader) {
|
|
|
2901
2783
|
(data) => String(data).split("\n").filter((line) => line && line.trim().length > 0).map((line) => line.trim())
|
|
2902
2784
|
);
|
|
2903
2785
|
}
|
|
2904
|
-
function
|
|
2786
|
+
function getBuildForLib(filepath, reader) {
|
|
2905
2787
|
if (!filepath) {
|
|
2906
2788
|
return Promise.resolve(void 0);
|
|
2907
2789
|
}
|
|
2908
2790
|
return readDirectory(filepath, reader).then(
|
|
2909
|
-
(items) => findSpecialFile(items, filepath, false
|
|
2791
|
+
(items) => findSpecialFile(items, filepath, false)
|
|
2910
2792
|
);
|
|
2911
2793
|
}
|
|
2912
2794
|
async function maybeBuildLib(spec) {
|
|
@@ -2997,8 +2879,8 @@ function checkBuiltLocally(reader, localPath) {
|
|
|
2997
2879
|
}
|
|
2998
2880
|
debug7("checkBuiltLocally passed");
|
|
2999
2881
|
}
|
|
3000
|
-
function checkIncludeItems(items
|
|
3001
|
-
const legalDots =
|
|
2882
|
+
function checkIncludeItems(items) {
|
|
2883
|
+
const legalDots = "../../../lib";
|
|
3002
2884
|
for (const item of items) {
|
|
3003
2885
|
if (!item || item.length === 0) {
|
|
3004
2886
|
continue;
|
|
@@ -3012,7 +2894,7 @@ function checkIncludeItems(items, web) {
|
|
|
3012
2894
|
}
|
|
3013
2895
|
return "";
|
|
3014
2896
|
}
|
|
3015
|
-
async function checkRemoteBuildPreReqs(filepath, project
|
|
2897
|
+
async function checkRemoteBuildPreReqs(filepath, project) {
|
|
3016
2898
|
debug7(`checking remote build pre-reqs for '${filepath}'`);
|
|
3017
2899
|
const reader = project.reader;
|
|
3018
2900
|
if ((await reader.getPathKind(filepath)).isDirectory) {
|
|
@@ -3021,7 +2903,7 @@ async function checkRemoteBuildPreReqs(filepath, project, web) {
|
|
|
3021
2903
|
debug7(`found an .include file for '${filepath}'`);
|
|
3022
2904
|
const items = await readFileAsList(include, reader);
|
|
3023
2905
|
debug7(`read ${items.length} .include items for '${filepath}'`);
|
|
3024
|
-
const msg = checkIncludeItems(items
|
|
2906
|
+
const msg = checkIncludeItems(items);
|
|
3025
2907
|
if (msg) {
|
|
3026
2908
|
throw new Error(msg);
|
|
3027
2909
|
}
|
|
@@ -3029,7 +2911,7 @@ async function checkRemoteBuildPreReqs(filepath, project, web) {
|
|
|
3029
2911
|
}
|
|
3030
2912
|
}
|
|
3031
2913
|
async function doRemoteActionBuild(action, project) {
|
|
3032
|
-
await checkRemoteBuildPreReqs(action.file, project
|
|
2914
|
+
await checkRemoteBuildPreReqs(action.file, project);
|
|
3033
2915
|
const { zip, output, outputPromise } = makeProjectSliceZip(action.file);
|
|
3034
2916
|
const pkgName = path4.basename(path4.dirname(action.file));
|
|
3035
2917
|
const actionName = pkgName === "default" ? action.name : path4.join(pkgName, action.name);
|
|
@@ -3142,7 +3024,6 @@ function makeConfigFromActionSpec(action, spec, pkgName) {
|
|
|
3142
3024
|
debug7("converting action spec to sliced project.yml: %O", action);
|
|
3143
3025
|
const {
|
|
3144
3026
|
targetNamespace,
|
|
3145
|
-
cleanNamespace,
|
|
3146
3027
|
parameters,
|
|
3147
3028
|
environment: globalEnv,
|
|
3148
3029
|
credentials,
|
|
@@ -3162,12 +3043,10 @@ function makeConfigFromActionSpec(action, spec, pkgName) {
|
|
|
3162
3043
|
webSecure,
|
|
3163
3044
|
annotations,
|
|
3164
3045
|
environment,
|
|
3165
|
-
limits
|
|
3166
|
-
clean
|
|
3046
|
+
limits
|
|
3167
3047
|
} = action;
|
|
3168
3048
|
const newSpec = {
|
|
3169
3049
|
targetNamespace,
|
|
3170
|
-
cleanNamespace,
|
|
3171
3050
|
parameters,
|
|
3172
3051
|
environment: globalEnv,
|
|
3173
3052
|
credentials,
|
|
@@ -3187,8 +3066,7 @@ function makeConfigFromActionSpec(action, spec, pkgName) {
|
|
|
3187
3066
|
annotations,
|
|
3188
3067
|
parameters: action.parameters,
|
|
3189
3068
|
environment,
|
|
3190
|
-
limits
|
|
3191
|
-
clean
|
|
3069
|
+
limits
|
|
3192
3070
|
};
|
|
3193
3071
|
removeUndefined(newSpec);
|
|
3194
3072
|
removeUndefined(newAction);
|
|
@@ -3251,9 +3129,6 @@ function makeProjectSliceZip(context) {
|
|
|
3251
3129
|
return { output, zip, outputPromise };
|
|
3252
3130
|
}
|
|
3253
3131
|
function computeTag(action) {
|
|
3254
|
-
if (!action) {
|
|
3255
|
-
return "web";
|
|
3256
|
-
}
|
|
3257
3132
|
if (action.package) {
|
|
3258
3133
|
return `${action.package}_${action.name}`;
|
|
3259
3134
|
}
|
|
@@ -3316,8 +3191,8 @@ async function invokeRemoteBuilder(zipped, owClient, feedback, action, encryptio
|
|
|
3316
3191
|
);
|
|
3317
3192
|
}
|
|
3318
3193
|
debug7("axios put of url was successful");
|
|
3319
|
-
const kind = action
|
|
3320
|
-
const activityName =
|
|
3194
|
+
const kind = action.runtime;
|
|
3195
|
+
const activityName = `function '${getActionName(action)}'`;
|
|
3321
3196
|
const runtime = (await canonicalRuntime(kind)).replace(":", "_");
|
|
3322
3197
|
const buildActionName = `${BUILDER_ACTION_STEM}${runtime}`;
|
|
3323
3198
|
debug7(
|
|
@@ -3349,7 +3224,7 @@ async function invokeRemoteBuilder(zipped, owClient, feedback, action, encryptio
|
|
|
3349
3224
|
function readDirectory(filepath, reader) {
|
|
3350
3225
|
return reader.readdir(filepath).then(filterFiles);
|
|
3351
3226
|
}
|
|
3352
|
-
function findSpecialFile(items, filepath, isAction
|
|
3227
|
+
function findSpecialFile(items, filepath, isAction) {
|
|
3353
3228
|
const files = items.filter((item) => !item.isDirectory);
|
|
3354
3229
|
let buildDotSh = false;
|
|
3355
3230
|
let buildDotCmd = false;
|
|
@@ -3375,29 +3250,21 @@ function findSpecialFile(items, filepath, isAction, isLib) {
|
|
|
3375
3250
|
);
|
|
3376
3251
|
} else if (isAction && (files.length === 0 || ignore2 && files.length === 1)) {
|
|
3377
3252
|
throw new Error(`Action directory ${filepath} has no files`);
|
|
3378
|
-
} else if (
|
|
3253
|
+
} else if (!isAction && (include || ignore2)) {
|
|
3379
3254
|
throw new Error(
|
|
3380
3255
|
`'.include' and '.ignore' are not supported in the 'lib' directory`
|
|
3381
3256
|
);
|
|
3382
3257
|
}
|
|
3383
|
-
if (process.platform === "win32") {
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
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
|
-
}
|
|
3258
|
+
if (buildDotCmd && process.platform === "win32") {
|
|
3259
|
+
return "build.cmd";
|
|
3260
|
+
}
|
|
3261
|
+
if (buildDotCmd && !buildDotSh) {
|
|
3262
|
+
throw new Error(
|
|
3263
|
+
`In ${filepath}: 'build.cmd' won't run on this platform and no 'build.sh' is provided`
|
|
3264
|
+
);
|
|
3265
|
+
}
|
|
3266
|
+
if (buildDotSh) {
|
|
3267
|
+
return "build.sh";
|
|
3401
3268
|
}
|
|
3402
3269
|
return npm ? "package.json" : include ? ".include" : "identify";
|
|
3403
3270
|
}
|
|
@@ -3927,7 +3794,7 @@ async function buildStructureParts(topLevel) {
|
|
|
3927
3794
|
includer,
|
|
3928
3795
|
reader
|
|
3929
3796
|
);
|
|
3930
|
-
configPart.libBuild = await
|
|
3797
|
+
configPart.libBuild = await getBuildForLib(lib, reader);
|
|
3931
3798
|
return [actionsPart, configPart];
|
|
3932
3799
|
}
|
|
3933
3800
|
function assembleInitialStructure(parts) {
|
|
@@ -4030,7 +3897,7 @@ function buildActionsPart(pkgsdir, displayPath, includer, reader) {
|
|
|
4030
3897
|
reader
|
|
4031
3898
|
).then((values) => {
|
|
4032
3899
|
const [strays, pkgs] = values;
|
|
4033
|
-
return {
|
|
3900
|
+
return { packages: pkgs, strays };
|
|
4034
3901
|
});
|
|
4035
3902
|
}
|
|
4036
3903
|
}
|
|
@@ -4306,7 +4173,7 @@ function readAndPrepare(path7, credentials, flags, feedback) {
|
|
|
4306
4173
|
}
|
|
4307
4174
|
function deploy(todeploy) {
|
|
4308
4175
|
debug11("Starting deploy");
|
|
4309
|
-
return
|
|
4176
|
+
return maybeLoadVersions(todeploy).then(doDeploy).then((results) => {
|
|
4310
4177
|
const statusDir = writeProjectStatus(
|
|
4311
4178
|
todeploy.filePath,
|
|
4312
4179
|
results,
|
|
@@ -4349,33 +4216,11 @@ async function readProject(projectPath, envPath, buildEnvPath, includer, request
|
|
|
4349
4216
|
return ans;
|
|
4350
4217
|
}
|
|
4351
4218
|
debug11("evaluating the just-read project: %O", ans);
|
|
4352
|
-
let needsLocalBuilds;
|
|
4353
4219
|
try {
|
|
4354
|
-
|
|
4355
|
-
debug11("needsLocalBuilds=%s", needsLocalBuilds);
|
|
4220
|
+
await checkBuildingRequirements(ans, requestRemote);
|
|
4356
4221
|
} catch (err) {
|
|
4357
4222
|
return errorStructure(err);
|
|
4358
4223
|
}
|
|
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
4224
|
return ans;
|
|
4380
4225
|
}
|
|
4381
4226
|
async function buildProject(project) {
|
|
@@ -4480,17 +4325,6 @@ async function wipeNamespace(credentials) {
|
|
|
4480
4325
|
debug11("Client opened");
|
|
4481
4326
|
return wipe(client, credentials);
|
|
4482
4327
|
}
|
|
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
4328
|
|
|
4495
4329
|
// src/watch.ts
|
|
4496
4330
|
var fs7 = __toESM(require("fs"));
|
|
@@ -4570,7 +4404,7 @@ var import_http = require("http");
|
|
|
4570
4404
|
var import_debug12 = __toESM(require("debug"));
|
|
4571
4405
|
|
|
4572
4406
|
// src/version.ts
|
|
4573
|
-
var version = "5.0.
|
|
4407
|
+
var version = "5.0.19";
|
|
4574
4408
|
|
|
4575
4409
|
// src/main.ts
|
|
4576
4410
|
var verboseError = (0, import_debug12.default)("nim:error");
|
|
@@ -4588,7 +4422,7 @@ var DefaultLogger = class {
|
|
|
4588
4422
|
msg = improveErrorMsg(msg, err);
|
|
4589
4423
|
verboseError("%O", err);
|
|
4590
4424
|
const bang = process.platform === "win32" ? "\xBB" : "\u203A";
|
|
4591
|
-
console.
|
|
4425
|
+
console.error(bang + " Error: " + msg);
|
|
4592
4426
|
}
|
|
4593
4427
|
exit(code) {
|
|
4594
4428
|
process.exit(code);
|
|
@@ -5041,7 +4875,6 @@ function improveErrorMsg(msg, err) {
|
|
|
5041
4875
|
runtimeForZipMid,
|
|
5042
4876
|
switchNamespace,
|
|
5043
4877
|
wipeNamespace,
|
|
5044
|
-
wipePackage,
|
|
5045
4878
|
writeSliceResult,
|
|
5046
4879
|
wskRequest
|
|
5047
4880
|
});
|