@entur/function-tools 0.0.2 → 0.0.4

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.
@@ -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.1").option("-v, --verbose", "Enable verbose output");
8
+ program.name("entur-functions").description("A multi-tool for Firebase functions at Entur").version("0.0.4").option("-v, --verbose", "Enable verbose output");
9
9
  registerBuild(program);
10
10
  registerDeploy(program);
11
11
  registerStart(program);
@@ -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 { createContext } from './utils.js';
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 createContext(options);
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);
@@ -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 { createContext } from './utils.js';
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 context = await createContext(options);
15
- await deploy(context);
14
+ const projectConfig = await resolveProjectConfig(options);
15
+ await deploy(projectConfig);
16
16
  } catch (error) {
17
17
  console.error(error);
18
18
  process.exit(1);
@@ -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 { createContext } from './utils.js';
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 context = await createContext(options);
14
- await start(context);
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 };
@@ -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 createContext({ outputDir = "dist", project, cwd = process.cwd() } = {}) {
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 { createContext };
71
+ export { resolveProjectConfig };
package/lib/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
+ export { ProjectConfig, resolveProjectConfig } from './commands/utils.js';
1
2
  export { Export, getExports } from './importExports/exports.js';
2
3
  export { Import, getImports } from './importExports/imports.js';
package/lib/index.js CHANGED
@@ -1,2 +1,3 @@
1
+ export { resolveProjectConfig } from './commands/utils.js';
1
2
  export { getExports } from './importExports/exports.js';
2
3
  export { getImports } from './importExports/imports.js';
package/package.json CHANGED
@@ -1,13 +1,16 @@
1
1
  {
2
2
  "name": "@entur/function-tools",
3
3
  "type": "module",
4
- "version": "0.0.2",
4
+ "version": "0.0.4",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
8
  "bin": {
9
9
  "entur-functions": "./bin/enturFunctions.js"
10
10
  },
11
+ "exports": {
12
+ ".": "./lib/index.js"
13
+ },
11
14
  "dependencies": {
12
15
  "@rollup/plugin-swc": "^0.4.0",
13
16
  "@rollup/plugin-node-resolve": "^16.0.3",