@eik/core 1.3.12 → 1.3.13

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/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [1.3.13](https://github.com/eik-lib/core/compare/v1.3.12...v1.3.13) (2022-10-18)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update dependency ssri to v10 ([#337](https://github.com/eik-lib/core/issues/337)) ([b474833](https://github.com/eik-lib/core/commit/b474833838915e8b505aab84a39fed4a361c5ebc))
7
+ * **deps:** update dependency unique-slug to v4 ([#336](https://github.com/eik-lib/core/issues/336)) ([bc2d673](https://github.com/eik-lib/core/commit/bc2d673cfaa150a10858bd452d91f76cffc4e0e5))
8
+
1
9
  ## [1.3.12](https://github.com/eik-lib/core/compare/v1.3.11...v1.3.12) (2022-10-05)
2
10
 
3
11
 
@@ -25,9 +25,6 @@ const Versions = class Versions {
25
25
  }
26
26
 
27
27
  setVersion(version, integrity) {
28
- if (!this.check(version)) {
29
- throw new Error('Semver version is lower than previous version');
30
- }
31
28
  const major = semver.major(version);
32
29
  this._versions.set(major, {
33
30
  version,
@@ -7,8 +7,9 @@ import abslog from 'abslog';
7
7
  import {
8
8
  createFilePathToPackage,
9
9
  createFilePathToVersion,
10
+ createFilePathToEikJson
10
11
  } from '../utils/path-builders-fs.js';
11
- import { decodeUriComponent, writeJSON, readJSON } from '../utils/utils.js';
12
+ import { decodeUriComponent, writeJSON, readJSON, readEikJson } from '../utils/utils.js';
12
13
  import { createURIPathToPkgLog } from '../utils/path-builders-uri.js';
13
14
  import MultipartParser from '../multipart/parser.js';
14
15
  import HttpIncoming from '../classes/http-incoming.js';
@@ -118,6 +119,24 @@ const PkgPut = class PkgPut {
118
119
  return versions;
119
120
  }
120
121
 
122
+ async _readVersion(incoming) {
123
+ const path = createFilePathToEikJson(incoming);
124
+ try {
125
+ await readEikJson(this._sink, path);
126
+ this._log.info(
127
+ `pkg:put - Found version meta file from sink - Pathname: ${path}`,
128
+ );
129
+ return true;
130
+ } catch (error) {
131
+
132
+ // File does not exist, its probably a new package
133
+ this._log.info(
134
+ `pkg:put - Did not find meta file in sink - Create new - Pathname: ${path}`,
135
+ );
136
+ return false;
137
+ }
138
+ }
139
+
121
140
  async _writeVersions(incoming, versions) {
122
141
  const path = createFilePathToVersion(incoming);
123
142
  await writeJSON(this._sink, path, versions, 'application/json');
@@ -127,6 +146,7 @@ const PkgPut = class PkgPut {
127
146
  }
128
147
 
129
148
  async handler(req, user, type, name, version) {
149
+
130
150
  const end = this._histogram.timer();
131
151
 
132
152
  const pVersion = decodeUriComponent(version);
@@ -163,17 +183,18 @@ const PkgPut = class PkgPut {
163
183
  org,
164
184
  });
165
185
 
166
- const versions = await this._readVersions(incoming);
186
+ const versionExists = await this._readVersion(incoming);
167
187
 
168
- if (!versions.check(pVersion)) {
188
+ if (versionExists) {
169
189
  this._log.info(
170
- `pkg:put - Semver version is lower than previous version of the package - Org: ${org} - Type: ${type} - Name: ${pName} - Version: ${pVersion}`,
190
+ `pkg:put - Semver version already exists for the package - Org: ${org} - Name: ${pName} - Version: ${pVersion}`,
171
191
  );
172
192
  const e = new HttpError.Conflict();
173
193
  end({ labels: { success: false, status: e.status, type } });
174
194
  throw e;
175
195
  }
176
196
 
197
+ const versions = await this._readVersions(incoming);
177
198
  const pkg = await this._parser(incoming);
178
199
  versions.setVersion(pVersion, pkg.integrity);
179
200
 
@@ -26,6 +26,8 @@ const createFilePathToAlias = ({ org = '', type = '', name = '', alias = '' } =
26
26
 
27
27
  const createFilePathToVersion = ({ org = '', type = '', name = '' } = {}) => path.join(globals.ROOT, org, type, name, 'versions.json')
28
28
 
29
+ const createFilePathToEikJson = ({ org = '', type = '', name = '', version } = {}) => path.join(globals.ROOT, org, type, name, version, 'eik.json')
30
+
29
31
  const createFilePathToAliasOrigin = ({org = '', type = '', name = '', version = '',} = {}) => {
30
32
  if(type === 'map') {
31
33
  return createFilePathToImportMap({org, name, version})
@@ -41,4 +43,5 @@ export {
41
43
  createFilePathToAlias,
42
44
  createFilePathToVersion,
43
45
  createFilePathToAliasOrigin,
46
+ createFilePathToEikJson,
44
47
  }
@@ -31,6 +31,8 @@ const readJSON = (sink, path) =>
31
31
  })
32
32
  ;
33
33
 
34
+ const readEikJson = (sink, path) => sink.exist(path);
35
+
34
36
  const writeJSON = (sink, path, obj, contentType) =>
35
37
  // eslint-disable-next-line no-async-promise-executor
36
38
  new Promise(async (resolve, reject) => {
@@ -89,4 +91,5 @@ export {
89
91
  streamCollector,
90
92
  etagFromFsStat,
91
93
  decodeUriComponent,
94
+ readEikJson
92
95
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eik/core",
3
- "version": "1.3.12",
3
+ "version": "1.3.13",
4
4
  "description": "Core server package",
5
5
  "main": "lib/main.js",
6
6
  "type": "module",
@@ -29,9 +29,9 @@
29
29
  "original-url": "1.2.3",
30
30
  "rimraf": "3.0.2",
31
31
  "semver": "7.3.8",
32
- "ssri": "9.0.1",
32
+ "ssri": "10.0.0",
33
33
  "tar": "6.1.11",
34
- "unique-slug": "2.0.2"
34
+ "unique-slug": "4.0.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@babel/eslint-parser": "7.19.1",