load-populate-files 1.0.1 → 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/dist/bin.d.ts +2 -1
- package/dist/bin.js +5 -1
- package/dist/cli.d.ts +9 -3
- package/dist/cli.js +17 -6
- package/dist/commands/lib/types.d.ts +14 -1
- package/dist/commands/lib/types.js +2 -1
- package/dist/commands/load-populate-files-command.d.ts +1 -0
- package/dist/commands/load-populate-files-command.js +3 -0
- package/dist/container.d.ts +3 -0
- package/dist/container.js +7 -0
- package/dist/lib/lib/populate-files-validator.d.ts +5 -11
- package/dist/lib/loader.js +8 -3
- package/package.json +14 -6
- package/.npmignore +0 -13
package/dist/bin.d.ts
CHANGED
package/dist/bin.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
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 {
|
|
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
|
|
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
|
-
|
|
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 {
|
|
3
|
-
import {
|
|
4
|
-
export class LoadPopulateFilesCli
|
|
5
|
-
|
|
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
|
-
|
|
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)
|
|
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
|
|
@@ -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
|
|
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
|
-
}
|
|
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
|
-
}
|
|
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
|
package/dist/lib/loader.js
CHANGED
|
@@ -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
|
-
|
|
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.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Load and dynamically populate file content",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=24"
|
|
@@ -27,16 +27,24 @@
|
|
|
27
27
|
"exports": {
|
|
28
28
|
".": "./dist/index.js"
|
|
29
29
|
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"!dist/**/*.map",
|
|
33
|
+
"!dist/tsconfig.tsbuildinfo",
|
|
34
|
+
"bin.mjs"
|
|
35
|
+
],
|
|
30
36
|
"bin": {
|
|
31
37
|
"load-populate-files": "./bin.mjs"
|
|
32
38
|
},
|
|
33
39
|
"dependencies": {
|
|
34
40
|
"ci-info": "^4.4.0",
|
|
35
41
|
"default-import": "^3.0.1",
|
|
36
|
-
"entry-script": "^4.0
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
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",
|
|
40
48
|
"populate-files": "^1.0.1",
|
|
41
49
|
"yargs": "^18.2.0"
|
|
42
50
|
},
|
|
@@ -51,7 +59,7 @@
|
|
|
51
59
|
"@types/yargs": "^17.0.35",
|
|
52
60
|
"@typescript/native": "npm:typescript@^7.0.2",
|
|
53
61
|
"c8": "^12.0.0",
|
|
54
|
-
"eslint": "^
|
|
62
|
+
"eslint": "^10.12.0",
|
|
55
63
|
"mocha": "^12.0.2",
|
|
56
64
|
"mocha-chain": "^1.0.1",
|
|
57
65
|
"typescript": "npm:@typescript/typescript6@^6.0.2"
|