@entur/function-tools 0.0.7 โ 0.0.8
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/build.js +12 -11
- package/lib/commands/deploy.js +8 -5
- package/lib/commands/start.js +6 -6
- package/lib/firebase/index.js +4 -2
- package/lib/utils/fs.js +1 -1
- 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.8").option("-v, --verbose", "Enable verbose output");
|
|
9
9
|
registerBuild(program);
|
|
10
10
|
registerDeploy(program);
|
|
11
11
|
registerStart(program);
|
package/lib/commands/build.js
CHANGED
|
@@ -7,24 +7,25 @@ import { getWorkspacePackageNames } from '../utils/workspace.js';
|
|
|
7
7
|
import { resolveProjectConfig } from './utils.js';
|
|
8
8
|
|
|
9
9
|
function registerBuild(program) {
|
|
10
|
-
program.command("build").description("Build the project").option("-o, --output-dir <dir>", "Output directory").action(async (
|
|
10
|
+
program.command("build").description("Build the project").option("-o, --output-dir <dir>", "Output directory").action(async ({ outputDir })=>{
|
|
11
11
|
try {
|
|
12
|
-
const projectConfig = await resolveProjectConfig(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
await cleanDir(outputDir);
|
|
17
|
-
console.log(`๐จ Building ${name}`);
|
|
18
|
-
const workspacePackages = await getWorkspacePackageNames(pnpmWorkspaceYAML);
|
|
19
|
-
const entryFile = new URL(exports$1?.["."] ?? "./index.js", packageRoot);
|
|
20
|
-
await build(entryFile, workspacePackages, projectConfig);
|
|
12
|
+
const projectConfig = await resolveProjectConfig({
|
|
13
|
+
outputDir
|
|
14
|
+
});
|
|
15
|
+
await build(projectConfig);
|
|
21
16
|
} catch (error) {
|
|
22
17
|
console.error(error);
|
|
23
18
|
process.exit(1);
|
|
24
19
|
}
|
|
25
20
|
});
|
|
26
21
|
}
|
|
27
|
-
async function build(
|
|
22
|
+
async function build({ packageRoot, projectRoot, packageJSON, outputDir, pnpmWorkspaceYAML }) {
|
|
23
|
+
const { name, exports: exports$1 } = await readPackageJSON(packageJSON);
|
|
24
|
+
console.log("๐งน Cleaning dist folder");
|
|
25
|
+
await cleanDir(outputDir);
|
|
26
|
+
console.log(`๐จ Building ${name}`);
|
|
27
|
+
const packagesToInline = await getWorkspacePackageNames(pnpmWorkspaceYAML);
|
|
28
|
+
const entryFile = new URL(exports$1?.["."] ?? "./index.js", packageRoot);
|
|
28
29
|
const { output } = await bundle(entryFile, {
|
|
29
30
|
outputDir,
|
|
30
31
|
packageRoot,
|
package/lib/commands/deploy.js
CHANGED
|
@@ -9,17 +9,20 @@ 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").option("--debug", "print verbose debug output and keep a debug log file", false).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).option("--force", "delete missing Cloud Functions and bypass interactive prompts", false).action(async ({ outputDir, project, ...options })=>{
|
|
13
13
|
try {
|
|
14
|
-
const projectConfig = await resolveProjectConfig(
|
|
15
|
-
|
|
14
|
+
const projectConfig = await resolveProjectConfig({
|
|
15
|
+
outputDir,
|
|
16
|
+
project
|
|
17
|
+
});
|
|
18
|
+
await deploy(options, projectConfig);
|
|
16
19
|
} catch (error) {
|
|
17
20
|
console.error(error);
|
|
18
21
|
process.exit(1);
|
|
19
22
|
}
|
|
20
23
|
});
|
|
21
24
|
}
|
|
22
|
-
async function deploy(
|
|
25
|
+
async function deploy(options, projectConfig) {
|
|
23
26
|
const { projectAlias, projectId, packageJSON, packageRoot, pnpmWorkspaceYAML, projectRoot, outputDir } = projectConfig;
|
|
24
27
|
const { name, exports: exports$1 } = await readPackageJSON(packageJSON);
|
|
25
28
|
const workspacePackages = await getWorkspacePackageNames(pnpmWorkspaceYAML);
|
|
@@ -35,7 +38,7 @@ async function deploy(debug, projectConfig) {
|
|
|
35
38
|
await deploy$1({
|
|
36
39
|
projectId,
|
|
37
40
|
cwd: outputDir,
|
|
38
|
-
|
|
41
|
+
...options
|
|
39
42
|
});
|
|
40
43
|
}
|
|
41
44
|
async function build(entryFile, packagesToInline, { outputDir, packageRoot, projectRoot }) {
|
package/lib/commands/start.js
CHANGED
|
@@ -9,20 +9,21 @@ 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)", false).option("--debug", "print verbose debug output and keep a debug log file", false).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 ({ outputDir, project, ...options })=>{
|
|
13
13
|
try {
|
|
14
14
|
const projectConfig = await resolveProjectConfig({
|
|
15
|
-
|
|
15
|
+
outputDir,
|
|
16
|
+
project,
|
|
16
17
|
isEmulator: true
|
|
17
18
|
});
|
|
18
|
-
await start(options
|
|
19
|
+
await start(options, projectConfig);
|
|
19
20
|
} catch (error) {
|
|
20
21
|
console.error(error);
|
|
21
22
|
process.exit(1);
|
|
22
23
|
}
|
|
23
24
|
});
|
|
24
25
|
}
|
|
25
|
-
async function start(
|
|
26
|
+
async function start(options, projectConfig) {
|
|
26
27
|
const { packageRoot, packageJSON, projectId, projectRoot, pnpmWorkspaceYAML, outputDir } = projectConfig;
|
|
27
28
|
const { name, exports: exports$1 } = await readPackageJSON(packageJSON);
|
|
28
29
|
const codebase = getPackageName(name);
|
|
@@ -41,8 +42,7 @@ async function start(debug, inspectFunctions, projectConfig) {
|
|
|
41
42
|
startEmulator({
|
|
42
43
|
projectId,
|
|
43
44
|
cwd: outputDir,
|
|
44
|
-
|
|
45
|
-
inspectFunctions
|
|
45
|
+
...options
|
|
46
46
|
}).catch((error)=>{
|
|
47
47
|
console.error(error);
|
|
48
48
|
});
|
package/lib/firebase/index.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { spawnAsync } from '../utils/exec.js';
|
|
2
2
|
|
|
3
3
|
const FUNCTIONS_DISCOVERY_TIMEOUT = "30";
|
|
4
|
-
function deploy({ projectId, cwd, debug }) {
|
|
4
|
+
function deploy({ projectId, cwd, debug, force }) {
|
|
5
5
|
const extraArgs = [];
|
|
6
6
|
if (debug) {
|
|
7
|
-
console.log("Environment variables:", process.env);
|
|
8
7
|
extraArgs.push("--debug");
|
|
9
8
|
}
|
|
9
|
+
if (force) {
|
|
10
|
+
extraArgs.push("--force");
|
|
11
|
+
}
|
|
10
12
|
return spawnAsync("firebase", [
|
|
11
13
|
"deploy",
|
|
12
14
|
"--only",
|
package/lib/utils/fs.js
CHANGED