@rotty3000/config-node 0.3.3 → 0.3.4

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.
@@ -0,0 +1,30 @@
1
+ # This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2
+ # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
3
+
4
+ name: Node.js CI
5
+
6
+ on:
7
+ push:
8
+ branches: [ "main" ]
9
+ pull_request:
10
+ branches: [ "main" ]
11
+
12
+ jobs:
13
+ build:
14
+
15
+ runs-on: ubuntu-latest
16
+
17
+ strategy:
18
+ matrix:
19
+ node-version: [16.x, 18.x]
20
+ # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
21
+
22
+ steps:
23
+ - uses: actions/checkout@v3
24
+ - name: Use Node.js ${{ matrix.node-version }}
25
+ uses: actions/setup-node@v3
26
+ with:
27
+ node-version: ${{ matrix.node-version }}
28
+ cache: 'npm'
29
+ - run: npm ci
30
+ - run: npm test
@@ -0,0 +1,4 @@
1
+ ## Release process
2
+
3
+ 1. Tag a commit (format `v#.#.#`)
4
+ 1. Run `npm publish --access public`
@@ -11,7 +11,14 @@ exports.applicationPackaged = {
11
11
  description: "From application property json files packaged with the app",
12
12
  priority: 1000,
13
13
  get: (key, providerCache, commonCache) => {
14
- const mainPath = (0, util_1.computeIfAbsent)(commonCache, 'require.main.path', () => { var _a; return (_a = require.main) === null || _a === void 0 ? void 0 : _a.path; });
14
+ const mainPath = (0, util_1.computeIfAbsent)(commonCache, 'require.main.path', () => {
15
+ var _a;
16
+ const mainPath = (0, util_1.getProjectRoot)();
17
+ if (mainPath) {
18
+ return mainPath;
19
+ }
20
+ return (_a = require.main) === null || _a === void 0 ? void 0 : _a.path;
21
+ });
15
22
  if (mainPath) {
16
23
  const configPath = node_path_1.default.join(mainPath, 'application.json');
17
24
  if (node_fs_1.default.existsSync(configPath)) {
@@ -1 +1 @@
1
- {"version":3,"file":"1000-application-packaged.js","sourceRoot":"","sources":["../../../src/config-node/providers/1000-application-packaged.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAyB;AACzB,0DAA6B;AAE7B,kCAAiD;AAEpC,QAAA,mBAAmB,GAAmB;IACjD,WAAW,EAAE,4DAA4D;IACzE,QAAQ,EAAE,IAAI;IACd,GAAG,EAAE,CAAC,GAAG,EAAE,aAAa,EAAE,WAAW,EAAE,EAAE;QACvC,MAAM,QAAQ,GAAG,IAAA,sBAAe,EAAC,WAAW,EAAE,mBAAmB,EAAE,GAAG,EAAE,WAAC,OAAA,MAAA,OAAO,CAAC,IAAI,0CAAE,IAAI,CAAA,EAAA,CAAC,CAAC;QAC7F,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,UAAU,GAAG,mBAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;YAC3D,IAAI,iBAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;gBAC9B,MAAM,IAAI,GAAG,IAAA,sBAAe,EAAC,aAAa,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,iBAAE,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;gBAC/G,IAAI,IAAI,EAAE,CAAC;oBACT,OAAO,IAAA,cAAO,EAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;gBAC5B,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC"}
1
+ {"version":3,"file":"1000-application-packaged.js","sourceRoot":"","sources":["../../../src/config-node/providers/1000-application-packaged.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAyB;AACzB,0DAA6B;AAE7B,kCAAiE;AAEpD,QAAA,mBAAmB,GAAmB;IACjD,WAAW,EAAE,4DAA4D;IACzE,QAAQ,EAAE,IAAI;IACd,GAAG,EAAE,CAAC,GAAG,EAAE,aAAa,EAAE,WAAW,EAAE,EAAE;QACvC,MAAM,QAAQ,GAAG,IAAA,sBAAe,EAAC,WAAW,EAAE,mBAAmB,EAAE,GAAG,EAAE;;YACtE,MAAM,QAAQ,GAAG,IAAA,qBAAc,GAAE,CAAC;YAClC,IAAI,QAAQ,EAAE,CAAC;gBACb,OAAO,QAAQ,CAAC;YAClB,CAAC;YACD,OAAO,MAAA,OAAO,CAAC,IAAI,0CAAE,IAAI,CAAC;QAC5B,CAAC,CAAC,CAAC;QACH,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,UAAU,GAAG,mBAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;YAC3D,IAAI,iBAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;gBAC9B,MAAM,IAAI,GAAG,IAAA,sBAAe,EAAC,aAAa,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,iBAAE,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;gBAC/G,IAAI,IAAI,EAAE,CAAC;oBACT,OAAO,IAAA,cAAO,EAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;gBAC5B,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC"}
@@ -1,5 +1,10 @@
1
1
  declare let verbose: boolean;
2
2
  declare const protectedKeys: string[];
3
+ /**
4
+ * A utility function to get the root folder of the parent project, use this function to get the application.json file
5
+ * when it's packaged in the client extension files.
6
+ * */
7
+ declare function getProjectRoot(): string;
3
8
  /**
4
9
  * A utility function for providers that implements lazy computation of values when the cache does not contain the specified key.
5
10
  *
@@ -16,4 +21,4 @@ declare function computeIfAbsent(cache: Map<string, any>, key: string, fn: () =>
16
21
  */
17
22
  declare function setVerbose(b: boolean): void;
18
23
  declare function unquote(it: any): any;
19
- export { protectedKeys, computeIfAbsent, setVerbose, verbose, unquote };
24
+ export { protectedKeys, computeIfAbsent, setVerbose, verbose, unquote, getProjectRoot };
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.unquote = exports.verbose = exports.setVerbose = exports.computeIfAbsent = exports.protectedKeys = void 0;
6
+ exports.getProjectRoot = exports.unquote = exports.verbose = exports.setVerbose = exports.computeIfAbsent = exports.protectedKeys = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const fs_1 = __importDefault(require("fs"));
4
9
  let verbose = false;
5
10
  exports.verbose = verbose;
6
11
  const protectedKeys = [
@@ -8,6 +13,26 @@ const protectedKeys = [
8
13
  'config.node.profiles.active'
9
14
  ];
10
15
  exports.protectedKeys = protectedKeys;
16
+ function findProjectRoot(currentPath = process.cwd()) {
17
+ const hasPackageJson = fs_1.default.existsSync(path_1.default.join(currentPath, 'package.json'));
18
+ if (hasPackageJson) {
19
+ return currentPath;
20
+ }
21
+ if (currentPath === path_1.default.resolve('/')) {
22
+ return null;
23
+ }
24
+ return findProjectRoot(path_1.default.dirname(currentPath));
25
+ }
26
+ /**
27
+ * A utility function to get the root folder of the parent project, use this function to get the application.json file
28
+ * when it's packaged in the client extension files.
29
+ * */
30
+ function getProjectRoot() {
31
+ const currentWorkingDirectory = process.cwd();
32
+ const projectRoot = findProjectRoot(currentWorkingDirectory);
33
+ return projectRoot;
34
+ }
35
+ exports.getProjectRoot = getProjectRoot;
11
36
  /**
12
37
  * A utility function for providers that implements lazy computation of values when the cache does not contain the specified key.
13
38
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/config-node/util/index.ts"],"names":[],"mappings":";;;AAAA,IAAI,OAAO,GAAY,KAAK,CAAC;AA0DuB,0BAAO;AAxD3D,MAAM,aAAa,GAAG;IACpB,0BAA0B;IAC1B,6BAA6B;CAC9B,CAAC;AAqDM,sCAAa;AAnDrB;;;;;;;GAOG;AACH,SAAS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AAE,CAAC;YACV,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AA2BsB,0CAAe;AAzBtC;;;;GAIG;AACH,SAAS,UAAU,CAAC,CAAU;IAC5B,kBAAA,OAAO,GAAG,CAAC,CAAC;AACd,CAAC;AAkBuC,gCAAU;AAhBlD,SAAS,OAAO,CAAC,EAAO;IACtB,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE,CAAC;QAC3B,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAC3C,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACzB,CAAC;aACI,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAClD,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACzB,CAAC;QAED,IAAI,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACrB,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAE4D,0BAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rotty3000/config-node",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "A library for obtaining external configuration for your application.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",