load-populate-files 1.0.0 → 1.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
@@ -4,7 +4,7 @@
4
4
  Load and dynamically populate file content based on a single file's config.
5
5
 
6
6
  [![npm package](https://badge.fury.io/js/load-populate-files.svg)](https://www.npmjs.com/package/load-populate-files)
7
- [![License](https://img.shields.io/npm/l/load-populate-files.svg)](https://github.com/JacobLey/leyman/blob/main/tools/load-populate-files/LICENSE)
7
+ [![License](https://img.shields.io/npm/l/load-populate-files.svg)](https://github.com/JacobLey/leyman/blob/main/apps/populate-files/load-populate-files/LICENSE)
8
8
 
9
9
  </div>
10
10
 
package/dist/bin.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- export { LoadPopulateFilesCli as default } from './cli.js';
1
+ declare const _default: import("haywire-launcher").WrapperMain;
2
+ export default _default;
2
3
  //# sourceMappingURL=bin.d.ts.map
package/dist/bin.js CHANGED
@@ -1,3 +1,7 @@
1
- export { LoadPopulateFilesCli as default } from './cli.js';
1
+ import { identifier } from 'haywire';
2
+ import { launch } from 'haywire-launcher';
3
+ import { LoadPopulateFilesCli } from './cli.js';
4
+ import { cliContainer } from './container.js';
5
+ export default launch(cliContainer, identifier(LoadPopulateFilesCli));
2
6
 
3
7
  //# sourceMappingURL=bin.js.map
package/dist/cli.d.ts CHANGED
@@ -1,11 +1,16 @@
1
- import { EntryScript } from 'entry-script';
1
+ import type { Main } from 'entry-script';
2
+ import type { RegisterCommand } from './commands/lib/types.js';
2
3
  /**
3
4
  * LoadPopulateFiles CLI. Run `./bin.mjs --help` for options.
4
5
  *
5
6
  * Uses `yargs` package for command line parsing and logic flow.
6
7
  */
7
- export declare class LoadPopulateFilesCli extends EntryScript {
8
+ export declare class LoadPopulateFilesCli implements Main {
8
9
  #private;
10
+ /**
11
+ * @param commands - every command the CLI runs
12
+ */
13
+ constructor(commands: readonly RegisterCommand[]);
9
14
  /**
10
15
  * Entry point to CLI script.
11
16
  *
@@ -13,6 +18,7 @@ export declare class LoadPopulateFilesCli extends EntryScript {
13
18
  *
14
19
  * @param argv - process arguments
15
20
  */
16
- static main(argv: string[]): Promise<void>;
21
+ main(argv: string[]): Promise<void>;
17
22
  }
23
+ export declare const loadPopulateFilesCliBinding: import("haywire").Binding<import("haywire").OutputHaywireId<import("haywire").HaywireId<LoadPopulateFilesCli, typeof LoadPopulateFilesCli, null, false, false, false, false, false>>, [import("haywire").HaywireId<RegisterCommand, null, null, true, false, false, false, false>], false>;
18
24
  //# sourceMappingURL=cli.d.ts.map
package/dist/cli.js CHANGED
@@ -1,14 +1,18 @@
1
1
  import yargs from 'yargs';
2
- import { EntryScript } from "entry-script";
3
- import { loadPopulateFilesCommand } from './commands/load-populate-files-command.js';
4
- export class LoadPopulateFilesCli extends EntryScript {
5
- static async main(argv) {
2
+ import { bind } from 'haywire';
3
+ import { commandId } from './commands/lib/types.js';
4
+ export class LoadPopulateFilesCli {
5
+ #commands;
6
+ constructor(commands){
7
+ this.#commands = commands;
8
+ }
9
+ async main(argv) {
6
10
  const packageJson = await import('../package.json', {
7
11
  with: {
8
12
  type: 'json'
9
13
  }
10
14
  });
11
- await yargs().scriptName('load-populate-files').option({
15
+ let cli = yargs().scriptName('load-populate-files').option({
12
16
  cwd: {
13
17
  type: 'string',
14
18
  default: '.',
@@ -20,7 +24,11 @@ export class LoadPopulateFilesCli extends EntryScript {
20
24
  describe: 'Target directory for resolving output file paths. Defaults to resolved cwd.',
21
25
  alias: 't'
22
26
  }
23
- }).strict().help().alias('help', 'info').version(packageJson.default.version).command(loadPopulateFilesCommand).parseAsync(argv, {}, LoadPopulateFilesCli.#yargsOutput);
27
+ }).strict().help().alias('help', 'info').version(packageJson.default.version);
28
+ for (const register of this.#commands){
29
+ cli = register(cli);
30
+ }
31
+ await cli.parseAsync(argv, {}, LoadPopulateFilesCli.#yargsOutput);
24
32
  }
25
33
  static #yargsOutput(e, _argv, log) {
26
34
  if (e) {
@@ -33,5 +41,8 @@ export class LoadPopulateFilesCli extends EntryScript {
33
41
  }
34
42
  }
35
43
  }
44
+ export const loadPopulateFilesCliBinding = bind(LoadPopulateFilesCli).withDependencies([
45
+ commandId
46
+ ]).withConstructorProvider();
36
47
 
37
48
  //# sourceMappingURL=cli.js.map
@@ -1,7 +1,20 @@
1
- import type { CommandModule } from 'yargs';
1
+ import type { Argv, CommandModule } from 'yargs';
2
2
  export interface LoadPopulateFilesCommandInput {
3
3
  cwd: string;
4
4
  targetDir: string;
5
5
  }
6
6
  export type Command<ExtendedInput extends LoadPopulateFilesCommandInput> = Pick<CommandModule<LoadPopulateFilesCommandInput, ExtendedInput>, 'builder' | 'command' | 'describe' | 'handler'>;
7
+ /**
8
+ * Adds a command to the CLI.
9
+ *
10
+ * Commands differ in the input their handler receives, so they cannot share an element type.
11
+ * Wrapping each in a function that registers it keeps every command type-checked against its own input.
12
+ */
13
+ export type RegisterCommand = (cli: Argv<LoadPopulateFilesCommandInput>) => Argv<LoadPopulateFilesCommandInput>;
14
+ /**
15
+ * Every command the CLI runs. Each command binds itself:
16
+ *
17
+ * `bind(commandId).withInstance(cli => cli.command(myCommand))`
18
+ */
19
+ export declare const commandId: import("haywire").HaywireId<RegisterCommand, null, null, true, false, false, false, false>;
7
20
  //# sourceMappingURL=types.d.ts.map
@@ -1,3 +1,4 @@
1
- export { };
1
+ import { identifier } from 'haywire';
2
+ export const commandId = identifier().list();
2
3
 
3
4
  //# sourceMappingURL=types.js.map
@@ -9,5 +9,6 @@ interface LoadPopulateFilesCommandExtendedInput extends LoadPopulateFilesCommand
9
9
  * Main `load-populate-files` command
10
10
  */
11
11
  export declare const loadPopulateFilesCommand: Command<LoadPopulateFilesCommandExtendedInput>;
12
+ export declare const loadPopulateFilesCommandBinding: import("haywire").Binding<import("haywire").OutputHaywireId<import("haywire").HaywireId<import("./lib/types.js").RegisterCommand, null, null, true, false, false, false, false>>, [], false>;
12
13
  export {};
13
14
  //# sourceMappingURL=load-populate-files-command.d.ts.map
@@ -1,5 +1,7 @@
1
1
  import { isCI } from 'ci-info';
2
+ import { bind } from 'haywire';
2
3
  import { loadAndPopulateFiles } from '../lib/load-populate-files.js';
4
+ import { commandId } from './lib/types.js';
3
5
  export const loadPopulateFilesCommand = {
4
6
  command: [
5
7
  '$0',
@@ -41,5 +43,6 @@ export const loadPopulateFilesCommand = {
41
43
  });
42
44
  }
43
45
  };
46
+ export const loadPopulateFilesCommandBinding = bind(commandId).withInstance((cli)=>cli.command(loadPopulateFilesCommand));
44
47
 
45
48
  //# sourceMappingURL=load-populate-files-command.js.map
@@ -0,0 +1,3 @@
1
+ export declare const cliModule: import("haywire").Module<[import("haywire").NonExtendable<import("./cli.js").LoadPopulateFilesCli, typeof import("./cli.js").LoadPopulateFilesCli, null, false, false, false>] | [import("haywire").NonExtendable<import("./cli.js").LoadPopulateFilesCli, typeof import("./cli.js").LoadPopulateFilesCli, null, false, false, true>] | [import("haywire").NonExtendable<import("./cli.js").LoadPopulateFilesCli, typeof import("./cli.js").LoadPopulateFilesCli, null, false, true, false>] | [import("haywire").NonExtendable<import("./cli.js").LoadPopulateFilesCli, typeof import("./cli.js").LoadPopulateFilesCli, null, false, true, true>], [import("haywire").NonExtendable<import("./commands/lib/types.js").RegisterCommand, null, null, true, false, false>] | [import("haywire").NonExtendable<import("./commands/lib/types.js").RegisterCommand, null, null, true, false, true>] | [import("haywire").NonExtendable<import("./commands/lib/types.js").RegisterCommand, null, null, true, true, false>] | [import("haywire").NonExtendable<import("./commands/lib/types.js").RegisterCommand, null, null, true, true, true>], [import("haywire").NonExtendable<import("./commands/lib/types.js").RegisterCommand, null, null, true, false, false>], false>;
2
+ export declare const cliContainer: import("haywire").SyncContainer<[import("haywire").NonExtendable<import("./cli.js").LoadPopulateFilesCli, typeof import("./cli.js").LoadPopulateFilesCli, null, false, false, false>] | [import("haywire").NonExtendable<import("./cli.js").LoadPopulateFilesCli, typeof import("./cli.js").LoadPopulateFilesCli, null, false, false, true>] | [import("haywire").NonExtendable<import("./cli.js").LoadPopulateFilesCli, typeof import("./cli.js").LoadPopulateFilesCli, null, false, true, false>] | [import("haywire").NonExtendable<import("./cli.js").LoadPopulateFilesCli, typeof import("./cli.js").LoadPopulateFilesCli, null, false, true, true>] | [import("haywire").NonExtendable<import("./commands/lib/types.js").RegisterCommand, null, null, true, false, false>] | [import("haywire").NonExtendable<import("./commands/lib/types.js").RegisterCommand, null, null, true, false, true>] | [import("haywire").NonExtendable<import("./commands/lib/types.js").RegisterCommand, null, null, true, true, false>] | [import("haywire").NonExtendable<import("./commands/lib/types.js").RegisterCommand, null, null, true, true, true>]>;
3
+ //# sourceMappingURL=container.d.ts.map
@@ -0,0 +1,7 @@
1
+ import { createContainer, createModule } from 'haywire';
2
+ import { loadPopulateFilesCliBinding } from './cli.js';
3
+ import { loadPopulateFilesCommandBinding } from './commands/load-populate-files-command.js';
4
+ export const cliModule = createModule(loadPopulateFilesCliBinding).addBinding(loadPopulateFilesCommandBinding);
5
+ export const cliContainer = createContainer(cliModule);
6
+
7
+ //# sourceMappingURL=container.js.map
@@ -1,14 +1,8 @@
1
- export declare const isPopulateFileParams: (x: unknown) => x is (Partial<{
1
+ export declare const isPopulateFileParams: (x: unknown) => x is {
2
2
  filePath: string;
3
- content: Promise<import("populate-files").FileContent> | import("populate-files").FileContent;
4
- }> & Required<Pick<{
3
+ content: (Promise<import("populate-files").FileContent> | import("populate-files").FileContent | undefined) & (Promise<import("populate-files").FileContent> | import("populate-files").FileContent);
4
+ }[] | {
5
5
  filePath: string;
6
- content: Promise<import("populate-files").FileContent> | import("populate-files").FileContent;
7
- }, "content" | "filePath">>)[] | (Partial<{
8
- filePath: string;
9
- content: Promise<import("populate-files").FileContent> | import("populate-files").FileContent;
10
- }> & Required<Pick<{
11
- filePath: string;
12
- content: Promise<import("populate-files").FileContent> | import("populate-files").FileContent;
13
- }, "content" | "filePath">>);
6
+ content: (Promise<import("populate-files").FileContent> | import("populate-files").FileContent | undefined) & (Promise<import("populate-files").FileContent> | import("populate-files").FileContent);
7
+ };
14
8
  //# sourceMappingURL=populate-files-validator.d.ts.map
@@ -1,12 +1,17 @@
1
1
  import { defaultImport } from 'default-import';
2
2
  import { isPopulateFileParams } from './lib/populate-files-validator.js';
3
3
  export const loadFile = async (filePath)=>{
4
- const mod = await import(filePath).catch((err)=>{
4
+ let mod;
5
+ try {
6
+ mod = await import(filePath);
7
+ } catch (err) {
5
8
  if (String(err).includes('ERR_MODULE_NOT_FOUND')) {
6
- throw new Error(`JS file not found: ${filePath}`);
9
+ throw new Error(`JS file not found: ${filePath}`, {
10
+ cause: err
11
+ });
7
12
  }
8
13
  throw err;
9
- });
14
+ }
10
15
  const params = defaultImport(mod);
11
16
  if (isPopulateFileParams(params)) {
12
17
  return [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "load-populate-files",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Load and dynamically populate file content",
5
5
  "engines": {
6
6
  "node": ">=24"
@@ -10,7 +10,8 @@
10
10
  "license": "MIT",
11
11
  "repository": {
12
12
  "type": "git",
13
- "url": "JacobLey/leyman"
13
+ "url": "git+https://github.com/JacobLey/leyman.git",
14
+ "directory": "apps/populate-files/load-populate-files"
14
15
  },
15
16
  "homepage": "https://github.com/JacobLey/leyman/tree/main/apps/populate-files/load-populate-files#readme",
16
17
  "bugs": {
@@ -26,17 +27,25 @@
26
27
  "exports": {
27
28
  ".": "./dist/index.js"
28
29
  },
30
+ "files": [
31
+ "dist",
32
+ "!dist/**/*.map",
33
+ "!dist/tsconfig.tsbuildinfo",
34
+ "bin.mjs"
35
+ ],
29
36
  "bin": {
30
37
  "load-populate-files": "./bin.mjs"
31
38
  },
32
39
  "dependencies": {
33
40
  "ci-info": "^4.4.0",
34
- "default-import": "^3.0.0",
35
- "entry-script": "^4.0.0",
36
- "juniper": "^2.0.0",
37
- "juniper-validator": "^0.1.0",
38
- "parse-cwd": "^2.0.0",
39
- "populate-files": "^1.0.0",
41
+ "default-import": "^3.0.1",
42
+ "entry-script": "^4.1.0",
43
+ "haywire": "^1.1.1",
44
+ "haywire-launcher": "^1.0.1",
45
+ "juniper": "^2.2.0",
46
+ "juniper-validator": "^0.2.1",
47
+ "parse-cwd": "^2.0.2",
48
+ "populate-files": "^1.0.1",
40
49
  "yargs": "^18.2.0"
41
50
  },
42
51
  "devDependencies": {
@@ -50,9 +59,9 @@
50
59
  "@types/yargs": "^17.0.35",
51
60
  "@typescript/native": "npm:typescript@^7.0.2",
52
61
  "c8": "^12.0.0",
53
- "eslint": "^9.39.5",
62
+ "eslint": "^10.12.0",
54
63
  "mocha": "^12.0.2",
55
- "mocha-chain": "^1.0.0",
64
+ "mocha-chain": "^1.0.1",
56
65
  "typescript": "npm:@typescript/typescript6@^6.0.2"
57
66
  },
58
67
  "imports": {
package/.npmignore DELETED
@@ -1,13 +0,0 @@
1
- CHANGELOG.md
2
- project.json
3
- tsconfig.json
4
-
5
- coverage/**
6
- eslint.config.js
7
-
8
- dist/tsconfig.tsbuildinfo
9
- dist/**/*.map
10
- dist-test/**
11
- test/**
12
-
13
- src/**