Skip to content

Commit c31dd31

Browse files
committed
Allow importing "vault-env/$SUBMODULE"
This package exports multiple modules which are intended to be required separately. This is a bit tricky with TypeScript: microsoft/TypeScript#8305 microsoft/TypeScript#33079 The only way to make this work is to get rid of the "./src" and "./dist" directories and dump everything at the top level. Ick.
1 parent 5127d63 commit c31dd31

13 files changed

+24
-16
lines changed

.eslintignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
/dist
1+
*.d.ts
2+
*.js
23
/node_modules
34
/.eslintrc.js

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/node_modules/
2-
/dist/
2+
*.d.ts
3+
*.js

.prettierignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/node_modules/
2-
/dist/
2+
*.d.ts
3+
*.js
34
/coverage/

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Changed
1111

1212
- All `Secretfile` entries must now have the form `VAR_NAME path/to/secret:key`. We no longer support values which are missing `:key`, or which have or nested `:key1:key1`.
13+
- The return type of `parseSecretfile` has changed.
1314
- The code has been ported to TypeScript.
1415
- All dependencies have been updated.

src/cli.ts renamed to cli.ts

File renamed without changes.

src/local.ts renamed to local.ts

File renamed without changes.

src/main.ts renamed to main.ts

File renamed without changes.

package.json

+8-7
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,22 @@
22
"name": "vault-env",
33
"version": "4.3.1",
44
"description": "Put your vault secrets in your process.env",
5-
"main": "dist/src/main.js",
6-
"types": "dist/src/main.d.ts",
5+
"main": "main.js",
6+
"types": "main.d.ts",
77
"files": [
8-
"dist/src/**/*.d.ts",
9-
"dist/src/**/*.js"
8+
"*.d.ts",
9+
"*.js"
1010
],
1111
"scripts": {
12+
"clean": "rm -f *.d.ts *.js test/*.d.ts test/index.js test/fakeVault*.js",
1213
"build": "tsc",
1314
"fmt": "prettier --write .",
14-
"lint": "eslint src/**/*.ts test/**/*.ts",
15-
"prepublish": "rm -rf dist && npm run build",
15+
"lint": "eslint *.ts test/**/*.ts",
16+
"prepublishOnly": "npm run clean && npm run build",
1617
"test": "mocha -r ts-node/register test/index.ts"
1718
},
1819
"bin": {
19-
"vault-env": "dist/src/cli.js"
20+
"vault-env": "cli.js"
2021
},
2122
"keywords": [
2223
"vault",

src/parseSecretfile.ts renamed to parseSecretfile.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import assert from "assert";
1+
import assert = require("assert");
22

33
const SECRETFILE_PATTERN = /^([a-zA-Z_][a-zA-Z0-9_]+)\s+([^:\s]+):(.+)$/;
44
const SECRETFILE_COMMENT_PATTERN = /(^#)|(^\s*$)/;
File renamed without changes.

src/rotate.ts renamed to rotate.ts

File renamed without changes.

test/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import assert from "assert";
1+
import assert = require("assert");
22
import { writeFileSync as writeFile } from "fs";
33
import { fileSync as tmpFile } from "tmp";
4-
import { SecretSource } from "../src/parseSecretfile";
5-
import prepare, { Options } from "../src/prepare";
4+
import { SecretSource } from "../parseSecretfile";
5+
import prepare, { Options } from "../prepare";
66
import { FakeVaultServer } from "./fakeVault";
77

88
const TEST_PORT = 39582;

tsconfig.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
1515
// "sourceMap": true, /* Generates corresponding '.map' file. */
1616
// "outFile": "./", /* Concatenate and emit output to single file. */
17-
"outDir": "./dist" /* Redirect output structure to the directory. */,
17+
/* "outDir" **MUST** be "./" until there's a fix for https://github.com/microsoft/TypeScript/issues/33079. */
18+
"outDir": "./" /* Redirect output structure to the directory. */,
1819
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
1920
// "composite": true, /* Enable project compilation */
2021
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
@@ -65,5 +66,7 @@
6566
/* Advanced Options */
6667
"skipLibCheck": true /* Skip type checking of declaration files. */,
6768
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
68-
}
69+
},
70+
"include": ["*.ts", "test/*.ts"],
71+
"exclude": ["node_modules"]
6972
}

0 commit comments

Comments
 (0)