@groundfloorcloud/cli 0.1.12 → 0.1.13
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/dist/index.js +30 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1795,8 +1795,36 @@ async function readOptional(filePath) {
|
|
|
1795
1795
|
return null;
|
|
1796
1796
|
}
|
|
1797
1797
|
}
|
|
1798
|
-
|
|
1798
|
+
var NODE_HANDLER_MISSING = "Function/Job/Schedule Node projects need a handler.js exporting `handler` at the project root (or a package.json \"main\" pointing at an existing file). The platform runs a generated /app/main.js that does require('./handler'); `npm start` is not run for these workload types. See the runtime docs for the handler signature.";
|
|
1799
|
+
async function exists(filePath) {
|
|
1800
|
+
try {
|
|
1801
|
+
return (await fs3.stat(filePath)).isFile();
|
|
1802
|
+
} catch {
|
|
1803
|
+
return false;
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
async function hasHandlerEntry(sourceDir) {
|
|
1807
|
+
if (await exists(path4.join(sourceDir, "handler.js"))) return true;
|
|
1808
|
+
const raw = await readOptional(path4.join(sourceDir, "package.json"));
|
|
1809
|
+
if (raw == null) return false;
|
|
1810
|
+
let main2;
|
|
1811
|
+
try {
|
|
1812
|
+
main2 = JSON.parse(raw).main;
|
|
1813
|
+
} catch {
|
|
1814
|
+
throw new Error("package.json is not valid JSON.");
|
|
1815
|
+
}
|
|
1816
|
+
if (typeof main2 !== "string" || !main2.trim()) return false;
|
|
1817
|
+
const resolved = path4.resolve(sourceDir, main2);
|
|
1818
|
+
const rel = path4.relative(sourceDir, resolved);
|
|
1819
|
+
if (rel.startsWith("..") || path4.isAbsolute(rel)) return false;
|
|
1820
|
+
return exists(resolved);
|
|
1821
|
+
}
|
|
1822
|
+
async function preflightNodePackage(sourceDir, workloadType = "service") {
|
|
1799
1823
|
const dockerfile = await readOptional(path4.join(sourceDir, "Dockerfile"));
|
|
1824
|
+
if (dockerfile == null && workloadType !== "service") {
|
|
1825
|
+
if (!await hasHandlerEntry(sourceDir)) throw new Error(NODE_HANDLER_MISSING);
|
|
1826
|
+
return;
|
|
1827
|
+
}
|
|
1800
1828
|
const needsStartScript = dockerfile == null || dockerfileRunsNpmStart(dockerfile);
|
|
1801
1829
|
if (!needsStartScript) return;
|
|
1802
1830
|
const raw = await readOptional(path4.join(sourceDir, "package.json"));
|
|
@@ -2005,7 +2033,7 @@ async function deployCommand(opts) {
|
|
|
2005
2033
|
}
|
|
2006
2034
|
}
|
|
2007
2035
|
if (runtime === "node") {
|
|
2008
|
-
await preflightNodePackage(pkg.sourceDir);
|
|
2036
|
+
await preflightNodePackage(pkg.sourceDir, workloadType);
|
|
2009
2037
|
}
|
|
2010
2038
|
const schedule = resolveDeploySchedule({
|
|
2011
2039
|
workloadType,
|
package/package.json
CHANGED