@antongolub/lockfile 0.0.0-snapshot.38 → 0.0.0-snapshot.40

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
@@ -1,14 +1,15 @@
1
1
  # @antongolub/lockfile
2
2
  > Read and write lockfiles with reasonable losses
3
3
 
4
- ## Motivation
4
+ <p><img alt="@antongolub/lockfile" src="./pics/pic.png" align="right" width="300">
5
5
  Each package manager brings its own philosophy of how to describe, store and control project dependencies.
6
- It _seems_ acceptable for developers, but literally becomes a ~~pain in *** ***~~ headache for isec, devops and release engineers.
6
+ It <i>seems</i> acceptable for developers, but literally becomes a <strike>pain in *** ***</strike> headache for isec, devops and release engineers.
7
7
  This lib is a naive attempt to build a pm-independent, generic, extensible and reliable deps representation.
8
8
 
9
9
  The `package.json` manifest contains its own deps requirements, the `lockfile` holds the deps resolution snapshot<sup>*</sup>,
10
10
  so both of them are required to build a dependency graph. We can try to convert this data into a normalized representation for further analysis and processing (for example, to fix vulnerabilities).
11
11
  And then, if necessary, try convert it back to the original/another format.
12
+ </p>
12
13
 
13
14
  ## Status
14
15
  Proof of concept. The API may change significantly ⚠️
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antongolub/lockfile",
3
- "version": "0.0.0-snapshot.38",
3
+ "version": "0.0.0-snapshot.40",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -54,7 +54,8 @@
54
54
  "build:cjs": "yarn run build:esm -- --cjs",
55
55
  "build:dts": "tsc --emitDeclarationOnly --skipLibCheck --outDir target/dts",
56
56
  "test": "yarn test:unit",
57
- "test:unit": "DEBUG=true c8 -r lcov -r text -o target/coverage -x src/scripts -x src/test uvu -r tsm -i helpers 'src/test/ts/'",
57
+ "test:unit": "c8 -r lcov -r text -o target/coverage -x src/scripts -x src/test uvu -r tsm -i helpers 'src/test/ts/'",
58
+ "test:debug": "DEBUG=true TEMP=temp yarn run test:unit",
58
59
  "publish:snap": "yarn build && npm publish --no-git-tag-version --tag snapshot"
59
60
  },
60
61
  "files": [
@@ -81,5 +82,5 @@
81
82
  "url": "https://github.com/antongolub/lockfile/issues"
82
83
  },
83
84
  "homepage": "https://github.com/antongolub/lockfile#readme",
84
- "packageManager": "yarn@3.1.1"
85
+ "packageManager": "yarn@4.0.1"
85
86
  }
@@ -166,15 +166,25 @@ var debug = Object.assign((...chunks) => {
166
166
  console.log(...chunks);
167
167
  }, {
168
168
  enable: process.env.DEBUG,
169
- json(data, name = `debug-${Math.random().toString(16).slice(2)}.json`, base = import_node_path.default.resolve(process.cwd(), "temp")) {
170
- if (!this.enable)
171
- return;
172
- if (typeof data === "string") {
173
- this.json(name, data);
174
- return;
175
- }
176
- const _data = typeof data === "function" ? data() : data;
177
- import_promises2.default.writeFile(import_node_path.default.resolve(base, name), JSON.stringify(_data, null, 2));
169
+ json(_0) {
170
+ return __async(this, arguments, function* (data, name = `debug-${Math.random().toString(16).slice(2)}.json`, base) {
171
+ if (!this.enable)
172
+ return;
173
+ if (typeof data === "string") {
174
+ yield this.json(name, data);
175
+ return;
176
+ }
177
+ const _data = typeof data === "function" ? data() : data;
178
+ const _base = base || (yield this.tempy());
179
+ yield import_promises2.default.writeFile(import_node_path.default.resolve(_base, name), JSON.stringify(_data, null, 2));
180
+ });
181
+ },
182
+ tempy() {
183
+ return __async(this, null, function* () {
184
+ const temp = import_node_path.default.resolve(process.cwd(), process.env.TEMP || "temp");
185
+ yield import_promises2.default.mkdir(temp, { recursive: true });
186
+ return temp;
187
+ });
178
188
  }
179
189
  });
180
190
  var unique = (arr) => [...new Set(arr)];
@@ -3,6 +3,7 @@ export declare const flushObject: (obj: Record<string, any>) => Record<string, a
3
3
  export declare const loadContents: (value: string) => Promise<string>;
4
4
  export declare const debug: ((...chunks: any[]) => void) & {
5
5
  enable: string | undefined;
6
- json(data: any, name?: any, base?: string): void;
6
+ json(data: any, name?: any, base?: string): Promise<void>;
7
+ tempy(): Promise<string>;
7
8
  };
8
9
  export declare const unique: (arr: string[]) => string[];
@@ -88,15 +88,21 @@ var debug = Object.assign((...chunks) => {
88
88
  console.log(...chunks);
89
89
  }, {
90
90
  enable: process.env.DEBUG,
91
- json(data, name = `debug-${Math.random().toString(16).slice(2)}.json`, base = path.resolve(process.cwd(), "temp")) {
91
+ async json(data, name = `debug-${Math.random().toString(16).slice(2)}.json`, base) {
92
92
  if (!this.enable)
93
93
  return;
94
94
  if (typeof data === "string") {
95
- this.json(name, data);
95
+ await this.json(name, data);
96
96
  return;
97
97
  }
98
98
  const _data = typeof data === "function" ? data() : data;
99
- fs2.writeFile(path.resolve(base, name), JSON.stringify(_data, null, 2));
99
+ const _base = base || await this.tempy();
100
+ await fs2.writeFile(path.resolve(_base, name), JSON.stringify(_data, null, 2));
101
+ },
102
+ async tempy() {
103
+ const temp = path.resolve(process.cwd(), process.env.TEMP || "temp");
104
+ await fs2.mkdir(temp, { recursive: true });
105
+ return temp;
100
106
  }
101
107
  });
102
108
  var unique = (arr) => [...new Set(arr)];