@entur/function-tools 0.0.2 → 0.0.3
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 +2 -2
- package/lib/commands/deploy.js +3 -3
- package/lib/commands/start.js +3 -3
- package/lib/commands/utils.d.ts +18 -0
- package/lib/commands/utils.js +2 -2
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- 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-firebase").description("A multi-command CLI built with commander").version("0.0.
|
|
8
|
+
program.name("entur-firebase").description("A multi-command CLI built with commander").version("0.0.3").option("-v, --verbose", "Enable verbose output");
|
|
9
9
|
registerBuild(program);
|
|
10
10
|
registerDeploy(program);
|
|
11
11
|
registerStart(program);
|
package/lib/commands/build.js
CHANGED
|
@@ -3,12 +3,12 @@ import { flattenDependencies, harmonizeDependencies, calculateDependencies } fro
|
|
|
3
3
|
import { cleanDir } from '../utils/fs.js';
|
|
4
4
|
import { readPackageJSON } from '../utils/packageJSON.js';
|
|
5
5
|
import { getWorkspacePackageNames } from '../utils/workspace.js';
|
|
6
|
-
import {
|
|
6
|
+
import { resolveProjectConfig } from './utils.js';
|
|
7
7
|
|
|
8
8
|
function registerBuild(program) {
|
|
9
9
|
program.command("build").description("Build the project").option("-o, --output-dir <dir>", "Output directory").action(async (options)=>{
|
|
10
10
|
try {
|
|
11
|
-
const { packageRoot, packageJSON, outputDir, pnpmWorkspaceYAML } = await
|
|
11
|
+
const { packageRoot, packageJSON, outputDir, pnpmWorkspaceYAML } = await resolveProjectConfig(options);
|
|
12
12
|
const { name, exports: exports$1 } = await readPackageJSON(packageJSON);
|
|
13
13
|
console.log("🧹 Cleaning dist folder");
|
|
14
14
|
await cleanDir(outputDir);
|
package/lib/commands/deploy.js
CHANGED
|
@@ -6,13 +6,13 @@ import { getFirebaseJSON, writeFirebaseJSON } from '../utils/firebase.js';
|
|
|
6
6
|
import { cleanDir, writeJSON } from '../utils/fs.js';
|
|
7
7
|
import { readPackageJSON, getPackageName, writePackageJSON } from '../utils/packageJSON.js';
|
|
8
8
|
import { getWorkspacePackageNames } from '../utils/workspace.js';
|
|
9
|
-
import {
|
|
9
|
+
import { resolveProjectConfig } from './utils.js';
|
|
10
10
|
|
|
11
11
|
function registerDeploy(program) {
|
|
12
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)=>{
|
|
13
13
|
try {
|
|
14
|
-
const
|
|
15
|
-
await deploy(
|
|
14
|
+
const projectConfig = await resolveProjectConfig(options);
|
|
15
|
+
await deploy(projectConfig);
|
|
16
16
|
} catch (error) {
|
|
17
17
|
console.error(error);
|
|
18
18
|
process.exit(1);
|
package/lib/commands/start.js
CHANGED
|
@@ -5,13 +5,13 @@ import { getFirebaseJSON, writeFirebaseJSON } from '../utils/firebase.js';
|
|
|
5
5
|
import { cleanDir, writeJSON } from '../utils/fs.js';
|
|
6
6
|
import { readPackageJSON, getPackageName, writePackageJSON } from '../utils/packageJSON.js';
|
|
7
7
|
import { getWorkspacePackageNames } from '../utils/workspace.js';
|
|
8
|
-
import {
|
|
8
|
+
import { resolveProjectConfig } from './utils.js';
|
|
9
9
|
|
|
10
10
|
function registerStart(program) {
|
|
11
11
|
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").action(async (options)=>{
|
|
12
12
|
try {
|
|
13
|
-
const
|
|
14
|
-
await start(
|
|
13
|
+
const projectConfig = await resolveProjectConfig(options);
|
|
14
|
+
await start(projectConfig);
|
|
15
15
|
} catch (error) {
|
|
16
16
|
console.error(error);
|
|
17
17
|
process.exit(1);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
type Options = {
|
|
2
|
+
outputDir?: string;
|
|
3
|
+
project?: string;
|
|
4
|
+
cwd?: string;
|
|
5
|
+
};
|
|
6
|
+
type ProjectConfig = {
|
|
7
|
+
pnpmWorkspaceYAML: URL;
|
|
8
|
+
packageJSON: URL;
|
|
9
|
+
outputDir: URL;
|
|
10
|
+
packageRoot: URL;
|
|
11
|
+
projectRoot: URL;
|
|
12
|
+
projectAlias: string;
|
|
13
|
+
projectId: string;
|
|
14
|
+
};
|
|
15
|
+
declare function resolveProjectConfig({ outputDir, project, cwd, }?: Options): Promise<ProjectConfig>;
|
|
16
|
+
|
|
17
|
+
export { resolveProjectConfig };
|
|
18
|
+
export type { ProjectConfig };
|
package/lib/commands/utils.js
CHANGED
|
@@ -2,7 +2,7 @@ import { pathToFileURL } from 'node:url';
|
|
|
2
2
|
import { findUp } from 'find-up-simple';
|
|
3
3
|
import { readJSON } from '../utils/fs.js';
|
|
4
4
|
|
|
5
|
-
async function
|
|
5
|
+
async function resolveProjectConfig({ outputDir = "dist", project, cwd = process.cwd() } = {}) {
|
|
6
6
|
const [pnpmWorkspacePath, packageJSONPath, firebaseRCPath] = await Promise.all([
|
|
7
7
|
findUp("pnpm-workspace.yaml", {
|
|
8
8
|
cwd
|
|
@@ -68,4 +68,4 @@ function getProjectAliasAndId({ default: defaultProjectId, ...projects }, projec
|
|
|
68
68
|
throw new Error(`No project with alias or id ${project} found in .firebaserc`);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
export {
|
|
71
|
+
export { resolveProjectConfig };
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED