@entur/function-tools 0.0.1 → 0.0.2

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/README.md CHANGED
@@ -1,2 +1,2 @@
1
- # firebase-tools
2
- Ekstra verktøy for firebase
1
+ # function-tools
2
+ Ekstra verktøy for firebase functions
@@ -9,26 +9,27 @@ import { createResolver } from '../importExports/resolve.js';
9
9
  import { createResolveImport } from '../importExports/resolveImports.js';
10
10
  import { createReadFileDependencies, extractUnusedExports } from '../importExports/unused.js';
11
11
  import { createCache } from '../importExports/utils.js';
12
- import { createContext } from './utils.js';
13
12
 
14
13
  function registerUnusedExports(program) {
15
- program.command("unused-exports").description("Check for unused exports").action(async ()=>{
14
+ program.command("unused-exports").description("Check for unused exports").option("-i, --include <pattern...>", "Include glob pattern", [
15
+ "**/*.ts"
16
+ ]).option("-e, --exclude <numbers...>", "Excude glob pattern", [
17
+ "**/node_modules"
18
+ ]).option("--ignore <numbers...>", "Ignore glob pattern", []).option("--extensions <numbers...>", "File extensions to resolve", [
19
+ ".ts"
20
+ ]).action(async (options)=>{
16
21
  try {
17
- const context = await createContext();
18
- await unusedExports([
19
- "**/*.+(ts|tsx)"
20
- ], [], {
21
- extensions: [
22
- ".ts"
23
- ]
24
- }, context);
22
+ const cwd = process.cwd();
23
+ await unusedExports(options.include, options.ignore, options.exclude, {
24
+ extensions: options.extensions
25
+ }, cwd);
25
26
  } catch (error) {
26
27
  console.error(error);
27
28
  process.exit(1);
28
29
  }
29
30
  });
30
31
  }
31
- async function unusedExports(patterns, ignorePatterns, resolverOptions, { cwd }) {
32
+ async function unusedExports(patterns, ignorePatterns, excludePatterns, resolverOptions, cwd) {
32
33
  const resolver = createResolver({
33
34
  conditionNames: [
34
35
  "import",
@@ -40,15 +41,10 @@ async function unusedExports(patterns, ignorePatterns, resolverOptions, { cwd })
40
41
  });
41
42
  const resolveImport = createResolveImport(resolver, getFileExports, getFileProxyExports);
42
43
  const readFileDependencies = createReadFileDependencies(getFileImports, getFileExports, resolveImport);
43
- const exclude = [
44
- "**/node_modules",
45
- "tools/createPackage/template",
46
- "tools/dependency/mocks"
47
- ];
48
44
  const fileDependencies = [];
49
45
  for await (const filePath of glob(patterns, {
50
46
  cwd,
51
- exclude
47
+ exclude: excludePatterns
52
48
  })){
53
49
  fileDependencies.push(await readFileDependencies(join(cwd, filePath)));
54
50
  }
@@ -2,8 +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 } = {}) {
6
- const cwd = process.cwd();
5
+ async function createContext({ outputDir = "dist", project, cwd = process.cwd() } = {}) {
7
6
  const [pnpmWorkspacePath, packageJSONPath, firebaseRCPath] = await Promise.all([
8
7
  findUp("pnpm-workspace.yaml", {
9
8
  cwd
@@ -36,8 +35,7 @@ async function createContext({ outputDir = "dist", project } = {}) {
36
35
  packageRoot: new URL("./", packageJSONUrl),
37
36
  projectRoot: new URL("./", pnpmWorkspaceYAML),
38
37
  projectAlias,
39
- projectId,
40
- cwd
38
+ projectId
41
39
  };
42
40
  }
43
41
  function getProjectAliasAndId({ default: defaultProjectId, ...projects }, project) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@entur/function-tools",
3
3
  "type": "module",
4
- "version": "0.0.1",
4
+ "version": "0.0.2",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },