1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00

Improve how is get the version data of the squid.

This commit is contained in:
Pedro Gutiérrez 2019-06-17 16:14:54 +02:00
parent 0ca5dae306
commit ba9dc0930d
6 changed files with 29 additions and 15 deletions

2
.gitignore vendored
View File

@ -5,3 +5,5 @@ coverage/
doc/
test/**/*.js
src/**/*.js
src/metadata\.json

5
package-lock.json generated
View File

@ -5327,11 +5327,6 @@
"pinkie": "^2.0.0"
}
},
"pjson": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/pjson/-/pjson-1.0.9.tgz",
"integrity": "sha512-4hRJH3YzkUpOlShRzhyxAmThSNnAaIlWZCAb27hd0pVUAXNUAHAO7XZbsPPvsCYwBFEScTmCCL6DGE8NyZ8BdQ=="
},
"pkg-dir": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-3.0.0.tgz",

View File

@ -19,6 +19,7 @@
"start": "npm link @oceanprotocol/keeper-contracts @oceanprotocol/secret-store-client && npm run build:watch",
"build": "npm run clean && npm run build:tsc && npm run build:dist",
"build:tsc": "tsc --sourceMap",
"build:metadata": "./scripts/get-metadata.js > src/metadata.json",
"build:dist": "cross-env NODE_ENV=production webpack",
"build:watch": "tsc -w",
"doc": "typedoc --mode modules --out ./doc/ ./src/",
@ -30,7 +31,9 @@
"release": "./node_modules/release-it/bin/release-it.js --src.tagName='v%s' --github.release --npm.publish --non-interactive",
"release-minor": "./node_modules/release-it/bin/release-it.js minor --src.tagName='v%s' --github.release --npm.publish --non-interactive",
"release-major": "./node_modules/release-it/bin/release-it.js major --src.tagName='v%s' --github.release --npm.publish --non-interactive",
"prepublishOnly": "npm run build"
"prepublishOnly": "npm run build",
"prebuild": "npm run build:metadata",
"postinstall": "npm run build:metadata"
},
"nyc": {
"include": [
@ -69,7 +72,6 @@
"bignumber.js": "^8.1.1",
"deprecated-decorator": "^0.1.6",
"node-fetch": "^2.6.0",
"pjson": "^1.0.9",
"save-file": "^2.3.1",
"uuid": "^3.3.2",
"web3": "1.0.0-beta.37",

14
scripts/get-metadata.js Executable file
View File

@ -0,0 +1,14 @@
#!/usr/bin/env node
'use strict';
const packageInfo = require('../package.json');
const execSync = require('child_process').execSync;
process.stdout.write(
JSON
.stringify({
version: require('../package.json').version,
commit: execSync(`git rev-parse HEAD`).toString().trim(),
}, null, ' ')
);

View File

@ -1,5 +1,5 @@
import * as keeperPackageJson from "@oceanprotocol/keeper-contracts/package.json"
import * as packageJson from "pjson"
import * as metadata from "../metadata.json"
import { Instantiable, InstantiableConfig } from "../Instantiable.abstract"
@ -10,19 +10,20 @@ export enum OceanPlatformTechStatus {
Working = "Working",
}
interface OceanPlatformTech {
export interface OceanPlatformTech {
name: string
version?: string
commit?: string
status: OceanPlatformTechStatus
}
interface OceanPlatformKeeperTech extends OceanPlatformTech {
export interface OceanPlatformKeeperTech extends OceanPlatformTech {
network?: string
keeperVersion?: string
contracts?: {[contractName: string]: string}
}
export interface OceanPlatformVersions extends Array<OceanPlatformKeeperTech | OceanPlatformTech> {
export interface OceanPlatformVersions {
squid: OceanPlatformKeeperTech
aquarius: OceanPlatformTech
brizo: OceanPlatformKeeperTech
@ -50,12 +51,13 @@ export class OceanVersions extends Instantiable {
}
public async get(): Promise<OceanPlatformVersions> {
const versions = ([] as any) as OceanPlatformVersions
const versions = {} as OceanPlatformVersions
// Squid
versions.squid = {
name: "Squid-js",
version: packageJson.version,
version: metadata.version,
commit: metadata.commit,
status: OceanPlatformTechStatus.Working,
network: (await this.ocean.keeper.getNetworkName()).toLowerCase(),
keeperVersion: keeperPackageJson.version,
@ -102,7 +104,6 @@ export class OceanVersions extends Instantiable {
// Status
const techs: OceanPlatformKeeperTech[] = Object.values(versions as any)
versions.push(...techs)
const networks = techs
.map(({network}) => network)

View File

@ -14,7 +14,7 @@ export * from "./ddo/DDO"
export * from "./ddo/MetaData"
export { OrderProgressStep, CreateProgressStep } from "./ocean/OceanAssets"
export { OceanPlatformTechStatus } from "./ocean/OceanVersions"
export { OceanPlatformTechStatus, OceanPlatformTech, OceanPlatformKeeperTech, OceanPlatformVersions } from "./ocean/OceanVersions"
export { AgreementTemplate } from "./keeper/contracts/templates"
export { Condition, ConditionState } from "./keeper/contracts/conditions"