load-populate-files 1.1.2 → 1.1.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/README.md CHANGED
@@ -8,7 +8,7 @@ Load and dynamically populate file content based on a single file's config.
8
8
 
9
9
  </div>
10
10
 
11
- Guides and the full reference are on the [docs site](https://jacobley.github.io/leyman/populate-files/guides/config-modules).
11
+ Guides and the full reference are on the [docs site](https://jacobley.github.io/leyman/packages/populate-files/), including [Config modules](https://jacobley.github.io/leyman/packages/populate-files/guides/config-modules) for this package.
12
12
 
13
13
  ## Contents
14
14
 
@@ -30,7 +30,7 @@ npm i load-populate-files
30
30
  ## Example
31
31
 
32
32
  ```ts
33
- // config.ts
33
+ // config.ts, compiled to config.js
34
34
  export default [
35
35
  {
36
36
  filePath: './foo.json',
@@ -54,7 +54,7 @@ await loadAndPopulateFiles({ filePath: './config.js' });
54
54
 
55
55
  `load-populate-files` is an ESM module. It must be `import`ed. To load from a CJS module, use dynamic import: `const { loadAndPopulateFiles } = await import('load-populate-files');`.
56
56
 
57
- Instead of calling `populateFiles()` directly, export file configs from a dedicated config module, then point `loadAndPopulateFiles()` at that file. The loaded file may export a single config object or an array of configs.
57
+ Instead of calling `populateFiles()` directly, export file configs from a dedicated config module, then point `loadAndPopulateFiles()` at that file. The config module is loaded with `import()`, so it must be JavaScript that Node can run: point at the compiled `.js`, not the `.ts` source. Its default export may be a single config object or an array of configs.
58
58
 
59
59
  This package is also available as a CLI:
60
60
 
@@ -78,15 +78,17 @@ Loads the config exported at `params.filePath` and passes it to [`populateFiles(
78
78
 
79
79
  **Returns** `Promise<PopulationResponse[]>`, from `populateFiles()`.
80
80
 
81
+ **Throws** (rejects) `Error` with `JS file not found: <path>` if the module doesn't exist, or with `File content does not fulfill populate-file input at: <path>` followed by a line per problem (e.g. `- 0.filePath: must have required property 'filePath'`) if the default export isn't a valid config. Errors from `populateFiles()` (such as a `PopulateFilesCheckError` with `check`) pass through. The CLI prints the error and exits with code 1.
82
+
81
83
  #### `options`
82
84
 
83
85
  Options are passed through to the underlying `populateFiles()` call. They are also available as CLI flags.
84
86
 
85
87
  | Property | CLI flag | Type | Default | Description |
86
88
  |----------|----------|------|---------|-------------|
87
- | `check` | `--ci` | `boolean` | `true` in CI, else `false` | If `true`, fails if writing a file would change its content. Useful for verifying version-controlled files are up to date before deployment. |
89
+ | `check` | `--ci`, `--check` (`--no-ci` to write in CI) | `boolean` | `true` in CI, else `false` | If `true`, fails if writing a file would change its content. Useful for verifying version-controlled files are up to date before deployment. |
88
90
  | `dryRun` | `--dry-run` | `boolean` | `false` | If `true`, does not write any files regardless of changes. Can still fail if `check` is `true`. |
89
- | `cwd` | `--cwd` | `string \| URL` | `process.env.PWD` | Used as the current working directory for `filePath` and re-used for relative `filePath`s in the loaded config. |
91
+ | `cwd` | `--cwd` | `string \| URL` | `process.cwd()` | Used as the current working directory for `filePath` and the `targetDir` and `manifest` paths. Must be an existing directory. |
90
92
  | `targetDir` | `--target-dir`, `-t` | `string` | `'.'` | Target directory for resolving output file paths. Resolved relative to `cwd`. |
91
93
  | `clean` | `--clean` | `boolean` | `false` | If `true`, removes files in `targetDir` that were not generated (with `manifest`, only files it lists). In `--ci` mode, fails instead of removing. |
92
94
  | `force` | `--force` | `boolean` | `false` | Applies to `signed` files and the `manifest`. If `true`, overwrites files that were edited, are not signed or not listed, or are malformed. See [`populate-files`](https://www.npmjs.com/package/populate-files#signed-files). |
@@ -4,6 +4,7 @@ import type { PopulateFileParams } from 'populate-files';
4
4
  *
5
5
  * @param filePath - absolute path to JS file
6
6
  * @returns list of populate-files params exported by the file
7
+ * @rejects {Error} if the file doesn't exist, fails to load, or doesn't export populate-files params
7
8
  */
8
9
  export declare const loadFile: (filePath: string) => Promise<PopulateFileParams[]>;
9
10
  //# sourceMappingURL=loader.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "load-populate-files",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "Load and dynamically populate file content",
5
5
  "engines": {
6
6
  "node": ">=24"
@@ -13,7 +13,7 @@
13
13
  "url": "git+https://github.com/JacobLey/leyman.git",
14
14
  "directory": "apps/populate-files/load-populate-files"
15
15
  },
16
- "homepage": "https://github.com/JacobLey/leyman/tree/main/apps/populate-files/load-populate-files#readme",
16
+ "homepage": "https://jacobley.github.io/leyman/packages/populate-files/",
17
17
  "bugs": {
18
18
  "url": "https://github.com/JacobLey/leyman/issues"
19
19
  },
@@ -38,15 +38,15 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "ci-info": "^4.4.0",
41
- "default-import": "^3.0.1",
42
- "entry-script": "^4.1.1",
43
- "haywire": "^2.0.2",
44
- "haywire-launcher": "^1.1.0",
45
- "juniper": "^2.4.1",
46
- "juniper-validator": "^0.5.0",
47
- "parse-cwd": "^2.0.2",
48
- "populate-files": "^1.1.2",
49
- "unknown-error": "^0.1.0",
41
+ "default-import": "^3.0.2",
42
+ "entry-script": "^4.1.2",
43
+ "haywire": "^2.0.4",
44
+ "haywire-launcher": "^1.1.1",
45
+ "juniper": "^2.5.0",
46
+ "juniper-validator": "^0.5.1",
47
+ "parse-cwd": "^2.0.3",
48
+ "populate-files": "^1.2.0",
49
+ "unknown-error": "^0.1.1",
50
50
  "yargs": "^18.2.0"
51
51
  },
52
52
  "devDependencies": {
@@ -54,16 +54,16 @@
54
54
  "@leyman/eslint-config": "^0.0.1",
55
55
  "@leyman/expect": "^0.0.1",
56
56
  "@swc/cli": "^0.8.1",
57
- "@swc/core": "^1.16.2",
57
+ "@swc/core": "^1.16.18",
58
58
  "@types/mocha": "^10.0.10",
59
59
  "@types/node": "^24.19.0",
60
60
  "@types/yargs": "^17.0.35",
61
61
  "@typescript/native": "npm:typescript@^7.0.2",
62
62
  "c8": "^12.0.0",
63
- "eslint": "^10.12.0",
64
- "generated-signature": "^0.1.1",
65
- "mocha": "^12.0.2",
66
- "mocha-chain": "^1.0.1",
63
+ "eslint": "^10.13.0",
64
+ "generated-signature": "^0.1.3",
65
+ "mocha": "^12.0.3",
66
+ "mocha-chain": "^1.0.2",
67
67
  "tmp-promise": "^3.0.3",
68
68
  "typescript": "npm:@typescript/typescript6@^6.0.2"
69
69
  },