@entur/function-tools 0.0.6 → 0.0.7
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/bin/enturFunctions.js +1 -1
- package/lib/commands/deploy.js +5 -4
- package/lib/commands/start.js +4 -3
- package/lib/firebase/index.js +19 -13
- package/package.json +1 -1
package/bin/enturFunctions.js
CHANGED
|
@@ -5,7 +5,7 @@ import { registerStart } from '../lib/commands/start.js';
|
|
|
5
5
|
import { registerUnusedExports } from '../lib/commands/unusedExports.js';
|
|
6
6
|
|
|
7
7
|
const program = new Command();
|
|
8
|
-
program.name("entur-functions").description("A multi-tool for Firebase functions at Entur").version("0.0.
|
|
8
|
+
program.name("entur-functions").description("A multi-tool for Firebase functions at Entur").version("0.0.7").option("-v, --verbose", "Enable verbose output");
|
|
9
9
|
registerBuild(program);
|
|
10
10
|
registerDeploy(program);
|
|
11
11
|
registerStart(program);
|
package/lib/commands/deploy.js
CHANGED
|
@@ -9,17 +9,17 @@ import { getWorkspacePackageNames } from '../utils/workspace.js';
|
|
|
9
9
|
import { resolveProjectConfig, copyEnvFiles } from './utils.js';
|
|
10
10
|
|
|
11
11
|
function registerDeploy(program) {
|
|
12
|
-
program.command("deploy").description("Deploy the project").option("-o, --output-dir <dir>", "Output directory").option("-P, --project <project id or alias>", "Project id or alias").action(async (options)=>{
|
|
12
|
+
program.command("deploy").description("Deploy the project").option("-o, --output-dir <dir>", "Output directory").option("-P, --project <project id or alias>", "Project id or alias").option("--debug", "print verbose debug output and keep a debug log file", false).action(async (options)=>{
|
|
13
13
|
try {
|
|
14
14
|
const projectConfig = await resolveProjectConfig(options);
|
|
15
|
-
await deploy(projectConfig);
|
|
15
|
+
await deploy(options.debug, projectConfig);
|
|
16
16
|
} catch (error) {
|
|
17
17
|
console.error(error);
|
|
18
18
|
process.exit(1);
|
|
19
19
|
}
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
|
-
async function deploy(projectConfig) {
|
|
22
|
+
async function deploy(debug, projectConfig) {
|
|
23
23
|
const { projectAlias, projectId, packageJSON, packageRoot, pnpmWorkspaceYAML, projectRoot, outputDir } = projectConfig;
|
|
24
24
|
const { name, exports: exports$1 } = await readPackageJSON(packageJSON);
|
|
25
25
|
const workspacePackages = await getWorkspacePackageNames(pnpmWorkspaceYAML);
|
|
@@ -34,7 +34,8 @@ async function deploy(projectConfig) {
|
|
|
34
34
|
console.log(`🚢 Deploying to ${projectAlias} (${projectId})`);
|
|
35
35
|
await deploy$1({
|
|
36
36
|
projectId,
|
|
37
|
-
cwd: outputDir
|
|
37
|
+
cwd: outputDir,
|
|
38
|
+
debug
|
|
38
39
|
});
|
|
39
40
|
}
|
|
40
41
|
async function build(entryFile, packagesToInline, { outputDir, packageRoot, projectRoot }) {
|
package/lib/commands/start.js
CHANGED
|
@@ -9,20 +9,20 @@ import { getWorkspacePackageNames } from '../utils/workspace.js';
|
|
|
9
9
|
import { resolveProjectConfig, copyEnvFiles } from './utils.js';
|
|
10
10
|
|
|
11
11
|
function registerStart(program) {
|
|
12
|
-
program.command("start").description("Start function emulator").option("-o, --output-dir <dir>", "Output directory").option("-P, --project <project id or alias>", "Project id or alias").option("--inspect-functions [port]", "emulate Cloud Functions in debug mode with the node inspector on the given port (9229 if not specified)").action(async (options)=>{
|
|
12
|
+
program.command("start").description("Start function emulator").option("-o, --output-dir <dir>", "Output directory").option("-P, --project <project id or alias>", "Project id or alias").option("--inspect-functions [port]", "emulate Cloud Functions in debug mode with the node inspector on the given port (9229 if not specified)", false).option("--debug", "print verbose debug output and keep a debug log file", false).action(async (options)=>{
|
|
13
13
|
try {
|
|
14
14
|
const projectConfig = await resolveProjectConfig({
|
|
15
15
|
...options,
|
|
16
16
|
isEmulator: true
|
|
17
17
|
});
|
|
18
|
-
await start(options.inspectFunctions
|
|
18
|
+
await start(options.debug, options.inspectFunctions, projectConfig);
|
|
19
19
|
} catch (error) {
|
|
20
20
|
console.error(error);
|
|
21
21
|
process.exit(1);
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
-
async function start(inspectFunctions, projectConfig) {
|
|
25
|
+
async function start(debug, inspectFunctions, projectConfig) {
|
|
26
26
|
const { packageRoot, packageJSON, projectId, projectRoot, pnpmWorkspaceYAML, outputDir } = projectConfig;
|
|
27
27
|
const { name, exports: exports$1 } = await readPackageJSON(packageJSON);
|
|
28
28
|
const codebase = getPackageName(name);
|
|
@@ -41,6 +41,7 @@ async function start(inspectFunctions, projectConfig) {
|
|
|
41
41
|
startEmulator({
|
|
42
42
|
projectId,
|
|
43
43
|
cwd: outputDir,
|
|
44
|
+
debug,
|
|
44
45
|
inspectFunctions
|
|
45
46
|
}).catch((error)=>{
|
|
46
47
|
console.error(error);
|
package/lib/firebase/index.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { spawnAsync } from '../utils/exec.js';
|
|
2
2
|
|
|
3
3
|
const FUNCTIONS_DISCOVERY_TIMEOUT = "30";
|
|
4
|
-
function deploy({ projectId, cwd }) {
|
|
4
|
+
function deploy({ projectId, cwd, debug }) {
|
|
5
|
+
const extraArgs = [];
|
|
6
|
+
if (debug) {
|
|
7
|
+
console.log("Environment variables:", process.env);
|
|
8
|
+
extraArgs.push("--debug");
|
|
9
|
+
}
|
|
5
10
|
return spawnAsync("firebase", [
|
|
6
11
|
"deploy",
|
|
7
12
|
"--only",
|
|
8
13
|
"functions,firestore",
|
|
9
14
|
"-P",
|
|
10
|
-
projectId
|
|
15
|
+
projectId,
|
|
16
|
+
...extraArgs
|
|
11
17
|
], {
|
|
12
18
|
cwd,
|
|
13
19
|
env: {
|
|
@@ -16,17 +22,17 @@ function deploy({ projectId, cwd }) {
|
|
|
16
22
|
}
|
|
17
23
|
});
|
|
18
24
|
}
|
|
19
|
-
function startEmulator({ projectId, cwd, inspectFunctions }) {
|
|
20
|
-
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
"--inspect-functions",
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
function startEmulator({ projectId, cwd, debug, inspectFunctions }) {
|
|
26
|
+
const extraArgs = [];
|
|
27
|
+
if (inspectFunctions) {
|
|
28
|
+
if (typeof inspectFunctions === "string") {
|
|
29
|
+
extraArgs.push("--inspect-functions", inspectFunctions);
|
|
30
|
+
} else {
|
|
31
|
+
extraArgs.push("--inspect-functions");
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (debug) {
|
|
35
|
+
extraArgs.push("--debug");
|
|
30
36
|
}
|
|
31
37
|
return spawnAsync("firebase", [
|
|
32
38
|
"emulators:start",
|