Skip to content

Commit

Permalink
Allow importing "vault-env/$SUBMODULE"
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
emk committed Aug 23, 2020
1 parent 5127d63 commit c31dd31
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/dist
*.d.ts
*.js
/node_modules
/.eslintrc.js
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/node_modules/
/dist/
*.d.ts
*.js
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/node_modules/
/dist/
*.d.ts
*.js
/coverage/
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- 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`.
- The return type of `parseSecretfile` has changed.
- The code has been ported to TypeScript.
- All dependencies have been updated.
File renamed without changes.
File renamed without changes.
File renamed without changes.
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@
"name": "vault-env",
"version": "4.3.1",
"description": "Put your vault secrets in your process.env",
"main": "dist/src/main.js",
"types": "dist/src/main.d.ts",
"main": "main.js",
"types": "main.d.ts",
"files": [
"dist/src/**/*.d.ts",
"dist/src/**/*.js"
"*.d.ts",
"*.js"
],
"scripts": {
"clean": "rm -f *.d.ts *.js test/*.d.ts test/index.js test/fakeVault*.js",
"build": "tsc",
"fmt": "prettier --write .",
"lint": "eslint src/**/*.ts test/**/*.ts",
"prepublish": "rm -rf dist && npm run build",
"lint": "eslint *.ts test/**/*.ts",
"prepublishOnly": "npm run clean && npm run build",
"test": "mocha -r ts-node/register test/index.ts"
},
"bin": {
"vault-env": "dist/src/cli.js"
"vault-env": "cli.js"
},
"keywords": [
"vault",
Expand Down
2 changes: 1 addition & 1 deletion src/parseSecretfile.ts → parseSecretfile.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from "assert";
import assert = require("assert");

const SECRETFILE_PATTERN = /^([a-zA-Z_][a-zA-Z0-9_]+)\s+([^:\s]+):(.+)$/;
const SECRETFILE_COMMENT_PATTERN = /(^#)|(^\s*$)/;
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions test/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import assert from "assert";
import assert = require("assert");
import { writeFileSync as writeFile } from "fs";
import { fileSync as tmpFile } from "tmp";
import { SecretSource } from "../src/parseSecretfile";
import prepare, { Options } from "../src/prepare";
import { SecretSource } from "../parseSecretfile";
import prepare, { Options } from "../prepare";
import { FakeVaultServer } from "./fakeVault";

const TEST_PORT = 39582;
Expand Down
7 changes: 5 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "./dist" /* Redirect output structure to the directory. */,
/* "outDir" **MUST** be "./" until there's a fix for https://github.com/microsoft/TypeScript/issues/33079. */
"outDir": "./" /* Redirect output structure to the directory. */,
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
Expand Down Expand Up @@ -65,5 +66,7 @@
/* Advanced Options */
"skipLibCheck": true /* Skip type checking of declaration files. */,
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
},
"include": ["*.ts", "test/*.ts"],
"exclude": ["node_modules"]
}

0 comments on commit c31dd31

Please sign in to comment.