@eik/core
Advanced tools
Comparing version 1.3.12 to 1.3.13
@@ -0,1 +1,9 @@ | ||
## [1.3.13](https://github.com/eik-lib/core/compare/v1.3.12...v1.3.13) (2022-10-18) | ||
### Bug Fixes | ||
* **deps:** update dependency ssri to v10 ([#337](https://github.com/eik-lib/core/issues/337)) ([b474833](https://github.com/eik-lib/core/commit/b474833838915e8b505aab84a39fed4a361c5ebc)) | ||
* **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)) | ||
## [1.3.12](https://github.com/eik-lib/core/compare/v1.3.11...v1.3.12) (2022-10-05) | ||
@@ -2,0 +10,0 @@ |
@@ -28,5 +28,2 @@ import semver from 'semver'; | ||
setVersion(version, integrity) { | ||
if (!this.check(version)) { | ||
throw new Error('Semver version is lower than previous version'); | ||
} | ||
const major = semver.major(version); | ||
@@ -33,0 +30,0 @@ this._versions.set(major, { |
@@ -10,4 +10,5 @@ import { validators } from '@eik/common'; | ||
createFilePathToVersion, | ||
createFilePathToEikJson | ||
} from '../utils/path-builders-fs.js'; | ||
import { decodeUriComponent, writeJSON, readJSON } from '../utils/utils.js'; | ||
import { decodeUriComponent, writeJSON, readJSON, readEikJson } from '../utils/utils.js'; | ||
import { createURIPathToPkgLog } from '../utils/path-builders-uri.js'; | ||
@@ -122,2 +123,20 @@ import MultipartParser from '../multipart/parser.js'; | ||
async _readVersion(incoming) { | ||
const path = createFilePathToEikJson(incoming); | ||
try { | ||
await readEikJson(this._sink, path); | ||
this._log.info( | ||
`pkg:put - Found version meta file from sink - Pathname: ${path}`, | ||
); | ||
return true; | ||
} catch (error) { | ||
// File does not exist, its probably a new package | ||
this._log.info( | ||
`pkg:put - Did not find meta file in sink - Create new - Pathname: ${path}`, | ||
); | ||
return false; | ||
} | ||
} | ||
async _writeVersions(incoming, versions) { | ||
@@ -132,2 +151,3 @@ const path = createFilePathToVersion(incoming); | ||
async handler(req, user, type, name, version) { | ||
const end = this._histogram.timer(); | ||
@@ -169,7 +189,7 @@ | ||
const versions = await this._readVersions(incoming); | ||
const versionExists = await this._readVersion(incoming); | ||
if (!versions.check(pVersion)) { | ||
if (versionExists) { | ||
this._log.info( | ||
`pkg:put - Semver version is lower than previous version of the package - Org: ${org} - Type: ${type} - Name: ${pName} - Version: ${pVersion}`, | ||
`pkg:put - Semver version already exists for the package - Org: ${org} - Name: ${pName} - Version: ${pVersion}`, | ||
); | ||
@@ -181,2 +201,3 @@ const e = new HttpError.Conflict(); | ||
const versions = await this._readVersions(incoming); | ||
const pkg = await this._parser(incoming); | ||
@@ -183,0 +204,0 @@ versions.setVersion(pVersion, pkg.integrity); |
@@ -29,2 +29,4 @@ import path from 'node:path'; | ||
const createFilePathToEikJson = ({ org = '', type = '', name = '', version } = {}) => path.join(globals.ROOT, org, type, name, version, 'eik.json') | ||
const createFilePathToAliasOrigin = ({org = '', type = '', name = '', version = '',} = {}) => { | ||
@@ -45,2 +47,3 @@ if(type === 'map') { | ||
createFilePathToAliasOrigin, | ||
createFilePathToEikJson, | ||
} |
@@ -34,2 +34,4 @@ import { Writable, Readable, pipeline } from 'node:stream'; | ||
const readEikJson = (sink, path) => sink.exist(path); | ||
const writeJSON = (sink, path, obj, contentType) => | ||
@@ -93,2 +95,3 @@ // eslint-disable-next-line no-async-promise-executor | ||
decodeUriComponent, | ||
readEikJson | ||
} |
{ | ||
"name": "@eik/core", | ||
"version": "1.3.12", | ||
"version": "1.3.13", | ||
"description": "Core server package", | ||
@@ -32,5 +32,5 @@ "main": "lib/main.js", | ||
"semver": "7.3.8", | ||
"ssri": "9.0.1", | ||
"ssri": "10.0.0", | ||
"tar": "6.1.11", | ||
"unique-slug": "2.0.2" | ||
"unique-slug": "4.0.0" | ||
}, | ||
@@ -37,0 +37,0 @@ "devDependencies": { |
123888
3088
+ Addedssri@10.0.0(transitive)
+ Addedunique-slug@4.0.0(transitive)
- Removedssri@9.0.1(transitive)
- Removedunique-slug@2.0.2(transitive)
Updatedssri@10.0.0
Updatedunique-slug@4.0.0