From 7d358406e8fb444ab8fe382694debaa00cf37a10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Grzywacz?= Date: Fri, 8 Sep 2023 09:04:32 +0200 Subject: [PATCH 01/34] feat(package.json): read name, description and manifest version from package.json file JST-385 --- package-lock.json | 16 +++++- package.json | 1 + src/manifest/manifest-create.action.ts | 74 ++++++++++++++++++++++--- src/manifest/manifest-create.command.ts | 16 ++++-- src/manifest/manifest-create.options.ts | 8 ++- 5 files changed, 95 insertions(+), 20 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3d52592..0361289 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,7 @@ "commander": "^11.0.0", "lodash": "^4.17.21", "luxon": "^3.4.3", + "new-find-package-json": "^2.0.0", "node-fetch": "^2.7.0", "typescript": "^5.2.2" }, @@ -3983,7 +3984,6 @@ "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "dev": true, "dependencies": { "ms": "2.1.2" }, @@ -6919,8 +6919,7 @@ "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "node_modules/natural-compare": { "version": "1.4.0", @@ -6940,6 +6939,17 @@ "integrity": "sha512-EZSPZB70jiVsivaBLYDCyntd5eH8NTSMOn3rB+HxwdmKThGELLdYv8qVIMWvZEFy9w8ZZpW9h9OB32l1rGtj7g==", "dev": true }, + "node_modules/new-find-package-json": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/new-find-package-json/-/new-find-package-json-2.0.0.tgz", + "integrity": "sha512-lDcBsjBSMlj3LXH2v/FW3txlh2pYTjmbOXPYJD93HI5EwuLzI11tdHSIpUMmfq/IOsldj4Ps8M8flhm+pCK4Ew==", + "dependencies": { + "debug": "^4.3.4" + }, + "engines": { + "node": ">=12.22.0" + } + }, "node_modules/node-emoji": { "version": "1.11.0", "resolved": "https://registry.npmjs.org/node-emoji/-/node-emoji-1.11.0.tgz", diff --git a/package.json b/package.json index f50a07c..a02ed7f 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "commander": "^11.0.0", "lodash": "^4.17.21", "luxon": "^3.4.3", + "new-find-package-json": "^2.0.0", "node-fetch": "^2.7.0", "typescript": "^5.2.2" }, diff --git a/src/manifest/manifest-create.action.ts b/src/manifest/manifest-create.action.ts index fa9910d..e17bd64 100644 --- a/src/manifest/manifest-create.action.ts +++ b/src/manifest/manifest-create.action.ts @@ -1,9 +1,10 @@ import { ManifestCreateOptions } from "./manifest-create.options"; import { ManifestDto, ManifestVersions } from "./dto"; -import { writeFile } from "fs/promises"; +import { readFile, writeFile } from "fs/promises"; import { checkFileOverwrite } from "../lib/file"; import fetch from "node-fetch"; import { DateTime } from "luxon"; +import { findAsync } from "new-find-package-json"; const repoUrl = "https://registry.golem.network"; @@ -105,19 +106,79 @@ async function getImage(imageSpec: string, providedHash?: string): Promise { +async function findPackageJson(possiblePath?: string): Promise { + if (possiblePath) { + return possiblePath; + } + + // Find first package.json file. + for await (const path of findAsync(process.cwd(), "package.json")) { + return path; + } +} + +async function fillOptionsWithPackageJson(options: ManifestCreateOptions): Promise { + if ("manifestVersion" in options && "name" in options && "description" in options) { + // All fields from package.json are provided. + return options; + } + + const path = await findPackageJson(options.packageJson); + if (!path) { + console.error( + 'Error: Cannot find package.json. Use "--package-json" option to specify its path or make sure --name, --description and --manifest-version are set.', + ); + process.exit(1); + } + + // Read package.json. + let packageData: string; + try { + packageData = await readFile(path, "utf-8"); + } catch (e) { + console.error(`Error: Cannot read ${path}: ${e}`); + process.exit(1); + } + + // Parse package.json + let packageJson: { version: string; name: string; description?: string }; + try { + packageJson = JSON.parse(packageData); + } catch (e) { + console.error(`Error: Cannot parse ${path}: ${e}`); + process.exit(1); + } + + if (!("manifestVersion" in options)) { + options.manifestVersion = packageJson.version; + } + + if (!("name" in options)) { + options.name = packageJson.name; + } + + if (!("description" in options)) { + options.description = packageJson.description; + } + + return options; +} + +export async function manifestCreateAction(image: string, options: ManifestCreateOptions): Promise { const imageData = await getImage(image, options.imageHash); const now = DateTime.now(); const expires = now.plus({ days: 90 }); // TODO: move that to options? + options = await fillOptionsWithPackageJson(options); + const manifest: ManifestDto = { version: ManifestVersions.GAP_5, createdAt: now.toISO() as string, expiresAt: expires.toISO() as string, metadata: { - name, + name: options.name!, description: options.description, - version: options.version, + version: options.manifestVersion!, }, payload: [ { @@ -132,11 +193,6 @@ export async function manifestCreateAction(name: string, image: string, options: }; // TODO: Add enquirer to ask for missing fields. - - manifest.metadata.name = name; - manifest.metadata.description = options.description; - manifest.metadata.version = options.version; - await checkFileOverwrite("Manifest", options.manifest, options.overwrite); await writeFile(options.manifest, JSON.stringify(manifest, null, 2)); diff --git a/src/manifest/manifest-create.command.ts b/src/manifest/manifest-create.command.ts index 7b45654..1393c39 100644 --- a/src/manifest/manifest-create.command.ts +++ b/src/manifest/manifest-create.command.ts @@ -7,12 +7,18 @@ manifestCreateCommand .description("Create a new Golem manifest.") .addOption(createManifestOption()) .option("-w, --overwrite", "Overwrite existing manifest (if present).") + .option("-n, --name ", "Name of the manifest/project.") .option("-d, --description ", "Description of the manifest.") - .option("-v, --version ", "Version of the manifest.", "1.0.0") - .option("-i, --image-hash ", "Image hash to be used in the manifest (format 'hash-function:hash-base64'") - .argument("", "Name of the manifest.") + .option("-v, --manifest-version ", "Version of the manifest.") + .option("-i, --image-hash ", "Image hash to be used in the manifest (format 'hash-function:hash-base64').") + .option("-p, --package-json ", "Package.json file to be used as information source.") .argument("", "Image to be used in the manifest, identified by URL, image tag or image hash.") - .action(async (name: string, image: string, options: ManifestCreateOptions) => { + .addHelpText( + "after", + "\npackage.json can be used to automatically fill manifest name, description and version." + + "\nIf package.json path is not provided, it will be looked for in current directory and all parent directories.", + ) + .action(async (image: string, options: ManifestCreateOptions) => { const action = await import("./manifest-create.action.js"); - await action.default.manifestCreateAction(name, image, options); + await action.default.manifestCreateAction(image, options); }); diff --git a/src/manifest/manifest-create.options.ts b/src/manifest/manifest-create.options.ts index c0245de..d96ef69 100644 --- a/src/manifest/manifest-create.options.ts +++ b/src/manifest/manifest-create.options.ts @@ -1,7 +1,9 @@ export interface ManifestCreateOptions { - version: string; + manifestVersion?: string; overwrite: boolean; - description: string; + name?: string; + description?: string; manifest: string; - imageHash: string; + imageHash?: string; + packageJson?: string; } From 9b75277e1dbcbc8b7f43b16b183748fc858d2f64 Mon Sep 17 00:00:00 2001 From: Grzegorz Godlewski Date: Thu, 7 Sep 2023 15:26:11 +0200 Subject: [PATCH 02/34] refactor: read version from package.json and used source and out dirs --- .gitignore | 3 ++- package.json | 5 ++--- src/lib/version.ts | 4 +++- tsconfig.json | 3 ++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index ab12063..a70c47e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ dist/ .vscode/ .DS_Store -manifest.json \ No newline at end of file +manifest.json +*.sig \ No newline at end of file diff --git a/package.json b/package.json index f50a07c..127d575 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,14 @@ { "name": "@golem-sdk/cli", - "version": "0.1.0", + "version": "1.0.0", "description": "CLI for Golem SDK", - "main": "dist/main.js", "repository": { "type": "github", "url": "github:GolemFactory/golem-sdk-cli" }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "build": "tsc", + "build": "tsc --build", "watch": "tsc --watch", "lint": "npm run lint:ts && npm run lint:eslint", "lint:ts": "tsc --project tsconfig.json --noEmit", diff --git a/src/lib/version.ts b/src/lib/version.ts index 094c1c8..4108d63 100644 --- a/src/lib/version.ts +++ b/src/lib/version.ts @@ -1,3 +1,5 @@ -import * as json from "../../package.json"; +import * as fs from "fs"; + +const json = JSON.parse(fs.readFileSync(__dirname + "/../../package.json").toString()); export const version = json.version; diff --git a/tsconfig.json b/tsconfig.json index 4076629..31c13dc 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,7 +16,8 @@ } }, "compilerOptions": { - "outDir": "dist", + "outDir": "dist/", + "rootDir": "src/", "experimentalDecorators": true, "resolveJsonModule": true, "moduleResolution": "node16" From e9d51b1c0fd50edfdc23954675afe715c7be28e4 Mon Sep 17 00:00:00 2001 From: Grzegorz Godlewski Date: Thu, 7 Sep 2023 16:01:02 +0200 Subject: [PATCH 03/34] refactor: be more verbose about actions and look for the last index of a certificate --- src/manifest/manifest-create.action.ts | 2 ++ src/manifest/manifest-sign.action.ts | 2 ++ src/manifest/manifest-verify.action.ts | 15 +++++++-------- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/manifest/manifest-create.action.ts b/src/manifest/manifest-create.action.ts index fa9910d..b5d0630 100644 --- a/src/manifest/manifest-create.action.ts +++ b/src/manifest/manifest-create.action.ts @@ -143,4 +143,6 @@ export async function manifestCreateAction(name: string, image: string, options: if (!imageData.hash) { console.log("Warning: Image hash is not specified. You won't be able to start an activity before you fill it out."); } + + console.log("Created manifest in %s file", options.manifest); } diff --git a/src/manifest/manifest-sign.action.ts b/src/manifest/manifest-sign.action.ts index 2825551..54b79d1 100644 --- a/src/manifest/manifest-sign.action.ts +++ b/src/manifest/manifest-sign.action.ts @@ -24,4 +24,6 @@ export async function manifestSignAction(options: ManifestSignOptions): Promise< // write signature to options.signatureFile. await writeFile(options.signatureFile, Buffer.from(signature).toString("base64"), "ascii"); + + console.log("Signed the manifest file and stored the signature in %s", options.signatureFile); } diff --git a/src/manifest/manifest-verify.action.ts b/src/manifest/manifest-verify.action.ts index 68f2219..abbb748 100644 --- a/src/manifest/manifest-verify.action.ts +++ b/src/manifest/manifest-verify.action.ts @@ -18,7 +18,13 @@ export async function manifestVerifyAction(options: ManifestVerifyOptions) { // FIXME: Find better way to get the second (or last?) certificate. const certInput = certFile.toString(); - const i = certInput.indexOf("-----BEGIN CERTIFICATE-----", 2); + const i = certInput.lastIndexOf("-----BEGIN CERTIFICATE-----"); + + if (i === -1) { + console.error("Could not locate the certificate to use for validation. Certificate file contents:", certFile.toString()); + process.exit(1); + } + const certSecond = certInput.substring(i); // const cert = new X509Certificate(certFile); @@ -33,12 +39,5 @@ export async function manifestVerifyAction(options: ManifestVerifyOptions) { } // TODO: Check if the certificate is not expired. - console.log("Manifest matches signature."); - /* - console.log('Certificate:', cert.publicKey.export({ - format: 'pem', - type: 'pkcs1', - })); -*/ } From bc6cba1251220d6cb3e185d3781ef39300c41401 Mon Sep 17 00:00:00 2001 From: Grzegorz Godlewski Date: Fri, 8 Sep 2023 09:12:05 +0200 Subject: [PATCH 04/34] chore: fixed formatting and introduced a pre-commit format check --- package-lock.json | 4 ++-- src/manifest/manifest-verify.action.ts | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3d52592..4fdcbb7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@golem-sdk/cli", - "version": "0.1.0", + "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@golem-sdk/cli", - "version": "0.1.0", + "version": "1.0.0", "license": "LGPL-3.0", "dependencies": { "@golem-sdk/golem-js": "^0.10.1", diff --git a/src/manifest/manifest-verify.action.ts b/src/manifest/manifest-verify.action.ts index abbb748..62b921b 100644 --- a/src/manifest/manifest-verify.action.ts +++ b/src/manifest/manifest-verify.action.ts @@ -21,7 +21,10 @@ export async function manifestVerifyAction(options: ManifestVerifyOptions) { const i = certInput.lastIndexOf("-----BEGIN CERTIFICATE-----"); if (i === -1) { - console.error("Could not locate the certificate to use for validation. Certificate file contents:", certFile.toString()); + console.error( + "Could not locate the certificate to use for validation. Certificate file contents:", + certFile.toString(), + ); process.exit(1); } From 05c17e4c200a0a9381cb4d85da49907018ce8268 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Grzywacz?= Date: Fri, 8 Sep 2023 09:29:32 +0200 Subject: [PATCH 05/34] fix(manifest sign): --private-key option is required and validated JST-386 --- src/lib/file.ts | 10 ++++++++++ src/manifest/manifest-sign.action.ts | 2 ++ src/manifest/manifest-sign.command.ts | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/lib/file.ts b/src/lib/file.ts index c5d5f4f..8627852 100644 --- a/src/lib/file.ts +++ b/src/lib/file.ts @@ -21,3 +21,13 @@ export async function checkFileOverwrite( // File does not exist, that's fine. } } + +export async function assertFileExists(name: string, path: string): Promise { + try { + await stat(path); + } catch (e) { + // File does not exist, that's fine. + console.error(`Error: ${name} "${path}" not found.`); + process.exit(1); + } +} diff --git a/src/manifest/manifest-sign.action.ts b/src/manifest/manifest-sign.action.ts index 2825551..f364ecf 100644 --- a/src/manifest/manifest-sign.action.ts +++ b/src/manifest/manifest-sign.action.ts @@ -2,10 +2,12 @@ import { ManifestSignOptions } from "./manifest-sign.options"; import { readManifest } from "./manifest-utils"; import { readFile, writeFile } from "fs/promises"; import { createSign } from "crypto"; +import { assertFileExists } from "../lib/file"; export async function manifestSignAction(options: ManifestSignOptions): Promise { // Read and validate the manifest. await readManifest(options.manifest); + await assertFileExists("Private key file", options.keyFile); // Read manifest buffer. const manifestBuffer = await readFile(options.manifest); diff --git a/src/manifest/manifest-sign.command.ts b/src/manifest/manifest-sign.command.ts index e310f2d..1b187e3 100644 --- a/src/manifest/manifest-sign.command.ts +++ b/src/manifest/manifest-sign.command.ts @@ -6,7 +6,7 @@ export const manifestSignCommand = new Command("sign"); manifestSignCommand .description("Sign Golem manifest file.") .addOption(createManifestOption()) - .option("-k, --key-file ", "Private key file.") + .requiredOption("-k, --key-file ", "Private key file.") .option("-p, --passphrase ", "Passphrase for the private key.") .option("-s, --signature-file ", "Signature file.", "manifest.sig") .action(async (options: ManifestSignOptions) => { From e4c152883f90a311049a854cd84f5a33484fe457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Grzywacz?= Date: Fri, 8 Sep 2023 10:07:39 +0200 Subject: [PATCH 06/34] fix(manifest verify): certificate file and signature file presence is checked JST-387 --- src/lib/file.ts | 9 +++++++-- src/manifest/manifest-sign.action.ts | 2 +- src/manifest/manifest-verify.action.ts | 4 ++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/lib/file.ts b/src/lib/file.ts index 8627852..40a1de2 100644 --- a/src/lib/file.ts +++ b/src/lib/file.ts @@ -22,12 +22,17 @@ export async function checkFileOverwrite( } } -export async function assertFileExists(name: string, path: string): Promise { +export async function assertFileExists(name: string, path: string, extraHelp?: string): Promise { try { await stat(path); } catch (e) { // File does not exist, that's fine. - console.error(`Error: ${name} "${path}" not found.`); + let message = `Error: ${name} "${path}" not found.`; + if (extraHelp) { + message += ` ${extraHelp}`; + } + + console.error(message); process.exit(1); } } diff --git a/src/manifest/manifest-sign.action.ts b/src/manifest/manifest-sign.action.ts index f364ecf..36e9abd 100644 --- a/src/manifest/manifest-sign.action.ts +++ b/src/manifest/manifest-sign.action.ts @@ -7,7 +7,7 @@ import { assertFileExists } from "../lib/file"; export async function manifestSignAction(options: ManifestSignOptions): Promise { // Read and validate the manifest. await readManifest(options.manifest); - await assertFileExists("Private key file", options.keyFile); + await assertFileExists("Private key file", options.keyFile, "Check --key-file option."); // Read manifest buffer. const manifestBuffer = await readFile(options.manifest); diff --git a/src/manifest/manifest-verify.action.ts b/src/manifest/manifest-verify.action.ts index 68f2219..7d2eea9 100644 --- a/src/manifest/manifest-verify.action.ts +++ b/src/manifest/manifest-verify.action.ts @@ -4,11 +4,15 @@ import { ManifestVerifyOptions } from "./manifest-verify.options"; import { X509Certificate } from "node:crypto"; import { readFile } from "fs/promises"; import { createVerify } from "crypto"; +import { assertFileExists } from "../lib/file"; export async function manifestVerifyAction(options: ManifestVerifyOptions) { // Read and validate the manifest. await readManifest(options.manifest); + await assertFileExists("Certificate file", options.certificateFile, "Check --certificate-file option."); + await assertFileExists("Signature file", options.signatureFile, "Check --signature-file option."); + // Read manifest buffer. const manifestBuffer = await readFile(options.manifest); const manifestBase64 = manifestBuffer.toString("base64"); From 47f193c58e63f3305edbd74ea416098d65ff7d09 Mon Sep 17 00:00:00 2001 From: Grzegorz Godlewski Date: Fri, 8 Sep 2023 11:17:37 +0200 Subject: [PATCH 07/34] build: configured release workflow on dry-run for testing --- .github/workflows/release.yml | 80 +++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..5c32d4a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,80 @@ +name: Release Pipeline + +on: + push: + branches: + # Regular release channels + - master + - next + - beta + - alpha + # Support, hotfix branches like: 1.0.x or 1.x + - '([0-9]+)(\.([0-9]+))?\.x' + + # Allows triggering the workflow manually + workflow_dispatch: + +# We're going to interact with GH from the pipelines, so we need to get some permissions +permissions: + contents: read # for checkout + +jobs: + regular-checks: + name: Build and unit-test on supported platforms and NodeJS versions + strategy: + matrix: + node-version: [16.x, 18.x, 20.x] + os: [ubuntu-latest, windows-latest, macos-latest] + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v3 + + - name: Setup NodeJS ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - name: Perform regular checks + run: | + npm install + npm run format:check + npm run lint + npm run build + + release: + name: Release to NPM and GitHub + needs: regular-checks + runs-on: ubuntu-latest + permissions: + contents: write # to be able to publish a GitHub release + issues: write # to be able to comment on released issues + pull-requests: write # to be able to comment on released pull requests + id-token: write # to enable use of OIDC for npm provenance + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup NodeJS + uses: actions/setup-node@v3 + with: + # Semantic release requires this as bare minimum + node-version: 18 + + - name: Install dependencies + run: npm install + + - name: Verify the integrity of provenance attestations and registry signatures for installed dependencies + run: npm audit signatures + + - name: Build the SDK for release + run: npm run build + + - name: Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + run: npx semantic-release --dry-run From 7152d355ef40b353d4418a535363eacf63501d84 Mon Sep 17 00:00:00 2001 From: Grzegorz Godlewski Date: Fri, 8 Sep 2023 11:27:39 +0200 Subject: [PATCH 08/34] build: disabled dry-run and added binary usage check to the regular checks --- .github/workflows/ci.yml | 2 ++ .github/workflows/release.yml | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 198318b..914167b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,3 +38,5 @@ jobs: npm run format:check npm run lint npm run build + npm ln + golem-sdk --version diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5c32d4a..4833e34 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -42,6 +42,8 @@ jobs: npm run format:check npm run lint npm run build + npm ln + golem-sdk --version release: name: Release to NPM and GitHub @@ -77,4 +79,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - run: npx semantic-release --dry-run + run: npx semantic-release From e2454e798bc83641143fdcc168aa4ee6c16c4e7f Mon Sep 17 00:00:00 2001 From: Grzegorz Godlewski Date: Fri, 8 Sep 2023 11:42:45 +0200 Subject: [PATCH 09/34] build: configured publish access to public to address release errors --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index a98c38b..765e876 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,9 @@ "type": "github", "url": "github:GolemFactory/golem-sdk-cli" }, + "publishConfig": { + "access": "public" + }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "build": "tsc --build", From 3fd834becad6d51a0be2ee815507ec818d286cd5 Mon Sep 17 00:00:00 2001 From: Grzegorz Godlewski Date: Fri, 8 Sep 2023 13:54:03 +0200 Subject: [PATCH 10/34] refactor: renamed golem-cli to golem-sdk in main.ts --- src/main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index 7a97af2..0cd12fc 100755 --- a/src/main.ts +++ b/src/main.ts @@ -3,7 +3,7 @@ import { Command } from "commander"; import { version } from "./lib/version"; import { manifestCommand } from "./manifest/manifest.command"; -const program = new Command("golem-cli"); +const program = new Command("golem-sdk"); program.version(version); // program.option('-n, --no-colors', 'Disable colors', (v) => { From a20ef07d9a56f39ec013610c773fa8de7a429a35 Mon Sep 17 00:00:00 2001 From: Grzegorz Godlewski Date: Fri, 8 Sep 2023 13:55:26 +0200 Subject: [PATCH 11/34] chore(deps): removed dependency on @golem-sdk/golem-js from the CLI --- package-lock.json | 532 +++------------------------------------------- package.json | 1 - 2 files changed, 32 insertions(+), 501 deletions(-) diff --git a/package-lock.json b/package-lock.json index cb3395b..a8ea57b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,6 @@ "version": "1.0.0", "license": "LGPL-3.0", "dependencies": { - "@golem-sdk/golem-js": "^0.10.1", "ajv": "^8.12.0", "ajv-formats": "^2.1.1", "commander": "^11.0.0", @@ -1109,29 +1108,6 @@ "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, - "node_modules/@golem-sdk/golem-js": { - "version": "0.10.1", - "resolved": "https://registry.npmjs.org/@golem-sdk/golem-js/-/golem-js-0.10.1.tgz", - "integrity": "sha512-HJ2AMqKeNr4dUXTSdnfaG9WxgW2tfL/7e8Xz5db4WfAmC6eg0wE5vM9qHJwuK/R5lqGjCytSROBdS6RuukCOdg==", - "dependencies": { - "@rauschma/stringio": "^1.4.0", - "axios": "^1.1.3", - "bottleneck": "^2.19.5", - "collect.js": "^4.34.3", - "eventsource": "^2.0.2", - "flatbuffers": "^23.5.26", - "ip-num": "^1.4.1", - "js-sha3": "^0.9.1", - "pino": "^8.11.0", - "pino-pretty": "^10.0.1", - "tmp": "^0.2.1", - "uuid": "^9.0.0", - "ya-ts-client": "^0.5.3" - }, - "engines": { - "node": ">=16.0.0" - } - }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.10", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.10.tgz", @@ -1853,19 +1829,6 @@ "node": ">=12" } }, - "node_modules/@rauschma/stringio": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/@rauschma/stringio/-/stringio-1.4.0.tgz", - "integrity": "sha512-3uor2f/MXZkmX5RJf8r+OC3WvZVzpSme0yyL0rQDPEnatE02qRcqwEwnsgpgriEck0S/n4vWtUd6tTtrJwk45Q==", - "dependencies": { - "@types/node": "^10.0.3" - } - }, - "node_modules/@rauschma/stringio/node_modules/@types/node": { - "version": "10.17.60", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.60.tgz", - "integrity": "sha512-F0KIgDJfy2nA3zMLmWGKxcH2ZVEtCZXHHdOQs2gSaQ27+lNeEfGxzkIw90aXswATX7AZ33tahPbzy6KAfUreVw==" - }, "node_modules/@semantic-release/commit-analyzer": { "version": "10.0.4", "resolved": "https://registry.npmjs.org/@semantic-release/commit-analyzer/-/commit-analyzer-10.0.4.tgz", @@ -3008,17 +2971,6 @@ "url": "https://opencollective.com/typescript-eslint" } }, - "node_modules/abort-controller": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", - "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", - "dependencies": { - "event-target-shim": "^5.0.0" - }, - "engines": { - "node": ">=6.5" - } - }, "node_modules/acorn": { "version": "8.10.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", @@ -3235,25 +3187,8 @@ "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" - }, - "node_modules/atomic-sleep": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/atomic-sleep/-/atomic-sleep-1.0.0.tgz", - "integrity": "sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==", - "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/axios": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.5.0.tgz", - "integrity": "sha512-D4DdjDo5CY50Qms0qGQTTw6Q44jl7zRwY7bthds06pUGfChBCTcQs+N743eFWGEd6pRTMd6A+I87aWyFV5wiZQ==", - "dependencies": { - "follow-redirects": "^1.15.0", - "form-data": "^4.0.0", - "proxy-from-env": "^1.1.0" - } + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "dev": true }, "node_modules/babel-jest": { "version": "29.6.4", @@ -3374,26 +3309,8 @@ "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" - }, - "node_modules/base64-js": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", - "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true }, "node_modules/before-after-hook": { "version": "2.2.3", @@ -3404,12 +3321,14 @@ "node_modules/bottleneck": { "version": "2.19.5", "resolved": "https://registry.npmjs.org/bottleneck/-/bottleneck-2.19.5.tgz", - "integrity": "sha512-VHiNCbI1lKdl44tGrhNfU3lup0Tj/ZBMJB5/2ZbNXRCPuRCO7ed2mgcK4r17y+KB2EfuYuRaVlwNbAeaWGSpbw==" + "integrity": "sha512-VHiNCbI1lKdl44tGrhNfU3lup0Tj/ZBMJB5/2ZbNXRCPuRCO7ed2mgcK4r17y+KB2EfuYuRaVlwNbAeaWGSpbw==", + "dev": true }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -3468,29 +3387,6 @@ "node-int64": "^0.4.0" } }, - "node_modules/buffer": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", - "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "dependencies": { - "base64-js": "^1.3.1", - "ieee754": "^1.2.1" - } - }, "node_modules/buffer-from": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", @@ -3683,11 +3579,6 @@ "integrity": "sha512-lHl4d5/ONEbLlJvaJNtsF/Lz+WvB07u2ycqTYbdrq7UypDXailES4valYb2eWiJFxZlVmpGekfqoxQhzyFdT4Q==", "dev": true }, - "node_modules/collect.js": { - "version": "4.36.1", - "resolved": "https://registry.npmjs.org/collect.js/-/collect.js-4.36.1.tgz", - "integrity": "sha512-jd97xWPKgHn6uvK31V6zcyPd40lUJd7gpYxbN2VOVxGWO4tyvS9Li4EpsFjXepGTo2tYcOTC4a8YsbQXMJ4XUw==" - }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -3706,15 +3597,11 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, - "node_modules/colorette": { - "version": "2.0.20", - "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.20.tgz", - "integrity": "sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==" - }, "node_modules/combined-stream": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dev": true, "dependencies": { "delayed-stream": "~1.0.0" }, @@ -3743,7 +3630,8 @@ "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true }, "node_modules/config-chain": { "version": "1.1.13", @@ -3972,14 +3860,6 @@ "node": ">=8" } }, - "node_modules/dateformat": { - "version": "4.6.3", - "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-4.6.3.tgz", - "integrity": "sha512-2P0p0pFGzHS5EMnhdxQi7aJN+iMheud0UhG4dlE1DLAlvL8JHjJJTX/CSm4JXwV0Ka5nGk3zC5mcb5bUQUxxMA==", - "engines": { - "node": "*" - } - }, "node_modules/debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", @@ -4072,6 +3952,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "dev": true, "engines": { "node": ">=0.4.0" } @@ -4208,14 +4089,6 @@ "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "dev": true }, - "node_modules/end-of-stream": { - "version": "1.4.4", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", - "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", - "dependencies": { - "once": "^1.4.0" - } - }, "node_modules/env-ci": { "version": "9.1.1", "resolved": "https://registry.npmjs.org/env-ci/-/env-ci-9.1.1.tgz", @@ -4557,30 +4430,6 @@ "node": ">=0.10.0" } }, - "node_modules/event-target-shim": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", - "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", - "engines": { - "node": ">=6" - } - }, - "node_modules/events": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", - "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", - "engines": { - "node": ">=0.8.x" - } - }, - "node_modules/eventsource": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-2.0.2.tgz", - "integrity": "sha512-IzUmBGPR3+oUG9dUeXynyNmf91/3zUSJg1lCktzKw47OXuhco54U3r9B7O4XX+Rb1Itm9OZ2b0RkTs10bICOxA==", - "engines": { - "node": ">=12.0.0" - } - }, "node_modules/execa": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", @@ -4629,11 +4478,6 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/fast-copy": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/fast-copy/-/fast-copy-3.0.1.tgz", - "integrity": "sha512-Knr7NOtK3HWRYGtHoJrjkaWepqT8thIVGAwt0p0aUs1zqkAzXZV4vo9fFNwyb5fcqK1GKYFYxldQdIDVKhUAfA==" - }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -4679,19 +4523,6 @@ "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", "dev": true }, - "node_modules/fast-redact": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/fast-redact/-/fast-redact-3.3.0.tgz", - "integrity": "sha512-6T5V1QK1u4oF+ATxs1lWUmlEk6P2T9HqJG3e2DnHOdVgZy2rFJBoEnrIedcTXlkAHU/zKC+7KETJ+KGGKwxgMQ==", - "engines": { - "node": ">=6" - } - }, - "node_modules/fast-safe-stringify": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz", - "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==" - }, "node_modules/fastq": { "version": "1.15.0", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz", @@ -4806,49 +4637,12 @@ "node": "^10.12.0 || >=12.0.0" } }, - "node_modules/flatbuffers": { - "version": "23.5.26", - "resolved": "https://registry.npmjs.org/flatbuffers/-/flatbuffers-23.5.26.tgz", - "integrity": "sha512-vE+SI9vrJDwi1oETtTIFldC/o9GsVKRM+s6EL0nQgxXlYV1Vc4Tk30hj4xGICftInKQKj1F3up2n8UbIVobISQ==" - }, "node_modules/flatted": { "version": "3.2.7", "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.7.tgz", "integrity": "sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==", "dev": true }, - "node_modules/follow-redirects": { - "version": "1.15.2", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", - "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/RubenVerborgh" - } - ], - "engines": { - "node": ">=4.0" - }, - "peerDependenciesMeta": { - "debug": { - "optional": true - } - } - }, - "node_modules/form-data": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", - "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/from2": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/from2/-/from2-2.3.0.tgz", @@ -4906,7 +4700,8 @@ "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true }, "node_modules/fsevents": { "version": "2.3.3", @@ -5076,6 +4871,7 @@ "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -5213,65 +5009,6 @@ "node": ">=8" } }, - "node_modules/help-me": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/help-me/-/help-me-4.2.0.tgz", - "integrity": "sha512-TAOnTB8Tz5Dw8penUuzHVrKNKlCIbwwbHnXraNJxPwf8LRtE2HlM84RYuezMFcwOJmoYOCWVDyJ8TQGxn9PgxA==", - "dependencies": { - "glob": "^8.0.0", - "readable-stream": "^3.6.0" - } - }, - "node_modules/help-me/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "node_modules/help-me/node_modules/glob": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", - "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^5.0.1", - "once": "^1.3.0" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/help-me/node_modules/minimatch": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", - "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/help-me/node_modules/readable-stream": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", - "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", - "dependencies": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/hook-std": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/hook-std/-/hook-std-3.0.0.tgz", @@ -5370,25 +5107,6 @@ "url": "https://github.com/sponsors/typicode" } }, - "node_modules/ieee754": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", - "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, "node_modules/ignore": { "version": "5.2.4", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", @@ -5467,6 +5185,7 @@ "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dev": true, "dependencies": { "once": "^1.3.0", "wrappy": "1" @@ -5475,7 +5194,8 @@ "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true }, "node_modules/ini": { "version": "1.3.8", @@ -5499,11 +5219,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/ip-num": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/ip-num/-/ip-num-1.5.1.tgz", - "integrity": "sha512-QziFxgxq3mjIf5CuwlzXFYscHxgLqdEdJKRo2UJ5GurL5zrSRMzT/O+nK0ABimoFH8MWF8YwIiwECYsHc1LpUQ==" - }, "node_modules/is-arrayish": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", @@ -6301,19 +6016,6 @@ "url": "https://github.com/chalk/supports-color?sponsor=1" } }, - "node_modules/joycon": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/joycon/-/joycon-3.1.1.tgz", - "integrity": "sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==", - "engines": { - "node": ">=10" - } - }, - "node_modules/js-sha3": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.9.1.tgz", - "integrity": "sha512-BEtdfjzc2zf276Ck8FprMl0ej0rFrK3TSwNSzFjDvv/QOj2YlWmoRBOIZaaUHFWJAXHl2KfiwVBIbYYeHHtCNA==" - }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -6841,6 +6543,7 @@ "version": "1.52.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "dev": true, "engines": { "node": ">= 0.6" } @@ -6849,6 +6552,7 @@ "version": "2.1.35", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dev": true, "dependencies": { "mime-db": "1.52.0" }, @@ -6878,6 +6582,7 @@ "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, "dependencies": { "brace-expansion": "^1.1.7" }, @@ -6889,6 +6594,7 @@ "version": "1.2.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "dev": true, "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -10154,15 +9860,11 @@ "inBundle": true, "license": "ISC" }, - "node_modules/on-exit-leak-free": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/on-exit-leak-free/-/on-exit-leak-free-2.1.0.tgz", - "integrity": "sha512-VuCaZZAjReZ3vUwgOB8LxAosIurDiAW0s13rI1YwmaP++jvcxP77AWoQvenZebpCA2m8WC1/EosPYPMjnRAp/w==" - }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, "dependencies": { "wrappy": "1" } @@ -10344,6 +10046,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true, "engines": { "node": ">=0.10.0" } @@ -10399,65 +10102,6 @@ "node": ">=4" } }, - "node_modules/pino": { - "version": "8.15.0", - "resolved": "https://registry.npmjs.org/pino/-/pino-8.15.0.tgz", - "integrity": "sha512-olUADJByk4twxccmAxb1RiGKOSvddHugCV3wkqjyv+3Sooa2KLrmXrKEWOKi0XPCLasRR5jBXxioE1jxUa4KzQ==", - "dependencies": { - "atomic-sleep": "^1.0.0", - "fast-redact": "^3.1.1", - "on-exit-leak-free": "^2.1.0", - "pino-abstract-transport": "v1.0.0", - "pino-std-serializers": "^6.0.0", - "process-warning": "^2.0.0", - "quick-format-unescaped": "^4.0.3", - "real-require": "^0.2.0", - "safe-stable-stringify": "^2.3.1", - "sonic-boom": "^3.1.0", - "thread-stream": "^2.0.0" - }, - "bin": { - "pino": "bin.js" - } - }, - "node_modules/pino-abstract-transport": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/pino-abstract-transport/-/pino-abstract-transport-1.0.0.tgz", - "integrity": "sha512-c7vo5OpW4wIS42hUVcT5REsL8ZljsUfBjqV/e2sFxmFEFZiq1XLUp5EYLtuDH6PEHq9W1egWqRbnLUP5FuZmOA==", - "dependencies": { - "readable-stream": "^4.0.0", - "split2": "^4.0.0" - } - }, - "node_modules/pino-pretty": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/pino-pretty/-/pino-pretty-10.2.0.tgz", - "integrity": "sha512-tRvpyEmGtc2D+Lr3FulIZ+R1baggQ4S3xD2Ar93KixFEDx6SEAUP3W5aYuEw1C73d6ROrNcB2IXLteW8itlwhA==", - "dependencies": { - "colorette": "^2.0.7", - "dateformat": "^4.6.3", - "fast-copy": "^3.0.0", - "fast-safe-stringify": "^2.1.1", - "help-me": "^4.0.1", - "joycon": "^3.1.1", - "minimist": "^1.2.6", - "on-exit-leak-free": "^2.1.0", - "pino-abstract-transport": "^1.0.0", - "pump": "^3.0.0", - "readable-stream": "^4.0.0", - "secure-json-parse": "^2.4.0", - "sonic-boom": "^3.0.0", - "strip-json-comments": "^3.1.1" - }, - "bin": { - "pino-pretty": "bin.js" - } - }, - "node_modules/pino-std-serializers": { - "version": "6.2.2", - "resolved": "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-6.2.2.tgz", - "integrity": "sha512-cHjPPsE+vhj/tnhCy/wiMh3M3z3h/j15zHQX+S9GkTBgqJuTuJzYJ4gUyACLhDaJ7kk9ba9iRDmbH2tJU03OiA==" - }, "node_modules/pirates": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.6.tgz", @@ -10661,25 +10305,12 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/process": { - "version": "0.11.10", - "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", - "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", - "engines": { - "node": ">= 0.6.0" - } - }, "node_modules/process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", "dev": true }, - "node_modules/process-warning": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-2.2.0.tgz", - "integrity": "sha512-/1WZ8+VQjR6avWOgHeEPd7SDQmFQ1B5mC1eRXsCm5TarlNmx/wCsa5GEaxGm05BORRtyG/Ex/3xq3TuRvq57qg==" - }, "node_modules/prompts": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", @@ -10699,20 +10330,6 @@ "integrity": "sha512-vtK/94akxsTMhe0/cbfpR+syPuszcuwhqVjJq26CuNDgFGj682oRBXOP5MJpv2r7JtE8MsiepGIqvvOTBwn2vA==", "dev": true }, - "node_modules/proxy-from-env": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", - "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" - }, - "node_modules/pump": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", - "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", - "dependencies": { - "end-of-stream": "^1.1.0", - "once": "^1.3.1" - } - }, "node_modules/punycode": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", @@ -10757,11 +10374,6 @@ } ] }, - "node_modules/quick-format-unescaped": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz", - "integrity": "sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg==" - }, "node_modules/quick-lru": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-4.0.1.tgz", @@ -10930,29 +10542,6 @@ "node": ">=8" } }, - "node_modules/readable-stream": { - "version": "4.4.2", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.4.2.tgz", - "integrity": "sha512-Lk/fICSyIhodxy1IDK2HazkeGjSmezAWX2egdtJnYhtzKEsBPJowlI6F6LPb5tqIQILrMbx22S5o3GuJavPusA==", - "dependencies": { - "abort-controller": "^3.0.0", - "buffer": "^6.0.3", - "events": "^3.3.0", - "process": "^0.11.10", - "string_decoder": "^1.3.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - } - }, - "node_modules/real-require": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/real-require/-/real-require-0.2.0.tgz", - "integrity": "sha512-57frrGM/OCTLqLOAh0mhVA9VBMHd+9U7Zb2THMGdBUoZVOtGbJzjxsYGDJ3A9AYYCP4hn6y1TVbaOfzWtm5GFg==", - "engines": { - "node": ">= 12.13.0" - } - }, "node_modules/redent": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/redent/-/redent-3.0.0.tgz", @@ -11086,6 +10675,7 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, "dependencies": { "glob": "^7.1.3" }, @@ -11123,6 +10713,7 @@ "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, "funding": [ { "type": "github", @@ -11138,19 +10729,6 @@ } ] }, - "node_modules/safe-stable-stringify": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.4.3.tgz", - "integrity": "sha512-e2bDA2WJT0wxseVd4lsDP4+3ONX6HpMXQa1ZhFQ7SU+GjvORCmShbCMltrtIDfkYhVHrOcPtj+KhmDBdPdZD1g==", - "engines": { - "node": ">=10" - } - }, - "node_modules/secure-json-parse": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/secure-json-parse/-/secure-json-parse-2.7.0.tgz", - "integrity": "sha512-6aU+Rwsezw7VR8/nyvKTx8QpWH9FrcYiXXlqC4z5d5XQBDRqtbfsRjnwGyqbi3gddNtWHuEk9OANUotL26qKUw==" - }, "node_modules/semantic-release": { "version": "21.1.1", "resolved": "https://registry.npmjs.org/semantic-release/-/semantic-release-21.1.1.tgz", @@ -11749,14 +11327,6 @@ "node": ">=8" } }, - "node_modules/sonic-boom": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-3.3.0.tgz", - "integrity": "sha512-LYxp34KlZ1a2Jb8ZQgFCK3niIHzibdwtwNUWKg0qQRzsDoJ3Gfgkf8KdBTFU3SkejDEIlWwnSnpVdOZIhFMl/g==", - "dependencies": { - "atomic-sleep": "^1.0.0" - } - }, "node_modules/source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -11830,6 +11400,7 @@ "version": "4.2.0", "resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz", "integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==", + "dev": true, "engines": { "node": ">= 10.x" } @@ -11905,6 +11476,7 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dev": true, "dependencies": { "safe-buffer": "~5.2.0" } @@ -11982,6 +11554,7 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, "engines": { "node": ">=8" }, @@ -12106,14 +11679,6 @@ "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "dev": true }, - "node_modules/thread-stream": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-2.4.0.tgz", - "integrity": "sha512-xZYtOtmnA63zj04Q+F9bdEay5r47bvpo1CaNqsKi7TpoJHcotUez8Fkfo2RJWpW91lnnaApdpRbVwCWsy+ifcw==", - "dependencies": { - "real-require": "^0.2.0" - } - }, "node_modules/through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", @@ -12143,17 +11708,6 @@ "node": ">= 6" } }, - "node_modules/tmp": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz", - "integrity": "sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ==", - "dependencies": { - "rimraf": "^3.0.0" - }, - "engines": { - "node": ">=8.17.0" - } - }, "node_modules/tmpl": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz", @@ -12397,15 +11951,8 @@ "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" - }, - "node_modules/uuid": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", - "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==", - "bin": { - "uuid": "dist/bin/uuid" - } + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "dev": true }, "node_modules/v8-compile-cache-lib": { "version": "3.0.1", @@ -12517,7 +12064,8 @@ "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true }, "node_modules/write-file-atomic": { "version": "4.0.2", @@ -12550,22 +12098,6 @@ "node": ">=10" } }, - "node_modules/ya-ts-client": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/ya-ts-client/-/ya-ts-client-0.5.3.tgz", - "integrity": "sha512-jwJmgmrb39NW/IKPjoH+ISKMCDna2Q9ylfmqQwVToKiOIrsnzt37ExxW6WxWrjJ5IZ8AkYfXQMOa2WRDvyZrJA==", - "dependencies": { - "axios": "^0.21.4" - } - }, - "node_modules/ya-ts-client/node_modules/axios": { - "version": "0.21.4", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz", - "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==", - "dependencies": { - "follow-redirects": "^1.14.0" - } - }, "node_modules/yallist": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", diff --git a/package.json b/package.json index 765e876..c115c9a 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,6 @@ "node": ">=16.0.0" }, "dependencies": { - "@golem-sdk/golem-js": "^0.10.1", "ajv": "^8.12.0", "ajv-formats": "^2.1.1", "commander": "^11.0.0", From 176636ec2ac5eed16ca4dfbdaaa7cb4449084ade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Grzywacz?= Date: Mon, 11 Sep 2023 10:04:37 +0200 Subject: [PATCH 12/34] feat(manifest sign): better passphrase handling in manifest sign command JST-396 --- src/manifest/manifest-sign.action.ts | 36 +++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/src/manifest/manifest-sign.action.ts b/src/manifest/manifest-sign.action.ts index 0ee84bc..c2c9081 100644 --- a/src/manifest/manifest-sign.action.ts +++ b/src/manifest/manifest-sign.action.ts @@ -14,15 +14,39 @@ export async function manifestSignAction(options: ManifestSignOptions): Promise< const manifestBase64 = manifestBuffer.toString("base64"); const keyFile = await readFile(options.keyFile); + let passphraseRequired = keyFile.toString("ascii").includes("BEGIN ENCRYPTED PRIVATE KEY"); - // Parse key file to KeyObject? + if (passphraseRequired && !options.passphrase) { + console.error("Error: Private key file is encrypted and no passphrase was provided. Use --passphrase option."); + process.exit(1); + } else if (!passphraseRequired && options.passphrase) { + console.error("Error: Private key file is not encrypted and passphrase was provided. Remove --passphrase option."); + process.exit(1); + } + + // Sign the manifest. + let signature: Buffer; const sign = createSign("RSA-SHA256"); sign.update(manifestBase64); - const signature = sign.sign({ - key: keyFile, - // FIXME: Allow secure passphrase input and detect if a passphrase is needed. - passphrase: options.passphrase, - }); + + try { + signature = sign.sign({ + key: keyFile, + passphrase: options.passphrase, + }); + } catch (e) { + if (e instanceof Error && "code" in e) { + if (e.code === "ERR_OSSL_BAD_DECRYPT") { + console.error(`Error: Wrong passphrase provided for the private key ${options.keyFile}.`); + process.exit(1); + } else if (e.code === "ERR_OSSL_UNSUPPORTED") { + console.error(`Error: Private key file ${options.keyFile} is not supported.`); + process.exit(1); + } + } + + throw e; + } // write signature to options.signatureFile. await writeFile(options.signatureFile, Buffer.from(signature).toString("base64"), "ascii"); From cea82f218b13fd9dc4f39598d2bd635b42631943 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Grzywacz?= Date: Mon, 11 Sep 2023 10:07:54 +0200 Subject: [PATCH 13/34] feat(manifest sign): better passphrase handling in manifest sign command JST-396 --- src/manifest/manifest-sign.action.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/manifest/manifest-sign.action.ts b/src/manifest/manifest-sign.action.ts index c2c9081..b7d3062 100644 --- a/src/manifest/manifest-sign.action.ts +++ b/src/manifest/manifest-sign.action.ts @@ -14,7 +14,7 @@ export async function manifestSignAction(options: ManifestSignOptions): Promise< const manifestBase64 = manifestBuffer.toString("base64"); const keyFile = await readFile(options.keyFile); - let passphraseRequired = keyFile.toString("ascii").includes("BEGIN ENCRYPTED PRIVATE KEY"); + const passphraseRequired = keyFile.toString("ascii").includes("BEGIN ENCRYPTED PRIVATE KEY"); if (passphraseRequired && !options.passphrase) { console.error("Error: Private key file is encrypted and no passphrase was provided. Use --passphrase option."); From c133dd6b048078451eaa8a1e9d546b52cf342432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Grzywacz?= Date: Mon, 11 Sep 2023 11:08:38 +0200 Subject: [PATCH 14/34] feat(manifest verify): certificate is now in pem format JST-395 --- src/lib/file.ts | 16 +++---- src/manifest/manifest-sign.action.ts | 6 ++- src/manifest/manifest-utils.ts | 15 +------ src/manifest/manifest-verify.action.ts | 43 +++++++++---------- src/manifest/manifest-verify.command.ts | 2 +- .../net/manifest-net-add-outbound.action.ts | 3 ++ 6 files changed, 37 insertions(+), 48 deletions(-) diff --git a/src/lib/file.ts b/src/lib/file.ts index 40a1de2..5ecf3b7 100644 --- a/src/lib/file.ts +++ b/src/lib/file.ts @@ -23,16 +23,16 @@ export async function checkFileOverwrite( } export async function assertFileExists(name: string, path: string, extraHelp?: string): Promise { + extraHelp = extraHelp ? ` ${extraHelp}` : ""; try { - await stat(path); - } catch (e) { - // File does not exist, that's fine. - let message = `Error: ${name} "${path}" not found.`; - if (extraHelp) { - message += ` ${extraHelp}`; - } + const stats = await stat(path); - console.error(message); + if (!stats.isFile()) { + console.error(`Error: "${path}" is not a file.${extraHelp}`); + process.exit(1); + } + } catch (e) { + console.error(`Error: ${name} "${path}" not found.${extraHelp}`); process.exit(1); } } diff --git a/src/manifest/manifest-sign.action.ts b/src/manifest/manifest-sign.action.ts index 0ee84bc..9dafa6e 100644 --- a/src/manifest/manifest-sign.action.ts +++ b/src/manifest/manifest-sign.action.ts @@ -5,10 +5,12 @@ import { createSign } from "crypto"; import { assertFileExists } from "../lib/file"; export async function manifestSignAction(options: ManifestSignOptions): Promise { - // Read and validate the manifest. - await readManifest(options.manifest); + await assertFileExists("Manifest file", options.manifest, "Check --manifest option."); await assertFileExists("Private key file", options.keyFile, "Check --key-file option."); + // Validate the manifest. We don't need parsed data, so output is ignored. + await readManifest(options.manifest); + // Read manifest buffer. const manifestBuffer = await readFile(options.manifest); const manifestBase64 = manifestBuffer.toString("base64"); diff --git a/src/manifest/manifest-utils.ts b/src/manifest/manifest-utils.ts index 5b51813..d5a226d 100644 --- a/src/manifest/manifest-utils.ts +++ b/src/manifest/manifest-utils.ts @@ -1,23 +1,10 @@ import { ManifestDto } from "./dto"; -import { Stats } from "fs"; -import { readFile, stat } from "fs/promises"; +import { readFile } from "fs/promises"; import schema from "./computation-payload-manifest.schema.json"; import Ajv from "ajv"; import addFormats from "ajv-formats"; export async function readManifest(filename: string): Promise { - let fileStats: Stats; - - try { - fileStats = await stat(filename); - } catch (e) { - throw new Error(`Error: Manifest file ${filename} can't be read: ${e}`); - } - - if (!fileStats.isFile()) { - throw new Error(`Error: Manifest file ${filename} is not a file.`); - } - let data: Buffer; try { data = await readFile(filename); diff --git a/src/manifest/manifest-verify.action.ts b/src/manifest/manifest-verify.action.ts index 2960ef9..1d0df7b 100644 --- a/src/manifest/manifest-verify.action.ts +++ b/src/manifest/manifest-verify.action.ts @@ -6,45 +6,42 @@ import { readFile } from "fs/promises"; import { createVerify } from "crypto"; import { assertFileExists } from "../lib/file"; -export async function manifestVerifyAction(options: ManifestVerifyOptions) { - // Read and validate the manifest. - await readManifest(options.manifest); +function getLastCertificate(certificateChain: string, certFile: string): string { + const i = certificateChain.lastIndexOf("-----BEGIN CERTIFICATE-----"); + if (i === -1) { + console.error(`Error: Could not locate the certificate to use for validation in ${certFile}.`); + process.exit(1); + } + + return certificateChain.substring(i); +} + +export async function manifestVerifyAction(options: ManifestVerifyOptions) { + await assertFileExists("Manifest file", options.manifest, "Check --manifest option."); await assertFileExists("Certificate file", options.certificateFile, "Check --certificate-file option."); await assertFileExists("Signature file", options.signatureFile, "Check --signature-file option."); + // Validate the manifest. We don't need parsed data, so output is ignored. + await readManifest(options.manifest); + // Read manifest buffer. const manifestBuffer = await readFile(options.manifest); const manifestBase64 = manifestBuffer.toString("base64"); - const certFile = Buffer.from(await readFile(options.certificateFile, "ascii"), "base64"); + const certFile = await readFile(options.certificateFile, "ascii"); const signature = Buffer.from(await readFile(options.signatureFile, "ascii"), "base64"); - // const signature = await readFile(options.signature, 'ascii'); - - // FIXME: Find better way to get the second (or last?) certificate. - const certInput = certFile.toString(); - const i = certInput.lastIndexOf("-----BEGIN CERTIFICATE-----"); - - if (i === -1) { - console.error( - "Could not locate the certificate to use for validation. Certificate file contents:", - certFile.toString(), - ); - process.exit(1); - } - - const certSecond = certInput.substring(i); - // const cert = new X509Certificate(certFile); - const cert = new X509Certificate(Buffer.from(certSecond)); + const certLast = getLastCertificate(certFile, options.certificateFile); + const cert = new X509Certificate(Buffer.from(certLast)); const verify = createVerify("RSA-SHA256"); verify.update(manifestBase64); if (!verify.verify(cert.publicKey, signature)) { - console.error("Manifest doesn't match signature."); + console.error("Error: Manifest doesn't match signature."); process.exit(1); } - // TODO: Check if the certificate is not expired. + // TODO: Check if the certificate and manifest are not expired. console.log("Manifest matches signature."); } diff --git a/src/manifest/manifest-verify.command.ts b/src/manifest/manifest-verify.command.ts index b8acd9b..28002cf 100644 --- a/src/manifest/manifest-verify.command.ts +++ b/src/manifest/manifest-verify.command.ts @@ -7,7 +7,7 @@ manifestVerifyCommand .summary("Verify manifest file.") .description("Verify manifest file for correctness and verify it's signature.") .addOption(createManifestOption()) - .option("-c, --certificate-file ", "Certificate file.", "manifest.cert") + .option("-c, --certificate-file ", "Certificate file.", "manifest.pem") .option("-s, --signature-file ", "Signature file (base64 encoded).", "manifest.sig") .action(async (options: ManifestVerifyOptions) => { const action = await import("./manifest-verify.action.js"); diff --git a/src/manifest/net/manifest-net-add-outbound.action.ts b/src/manifest/net/manifest-net-add-outbound.action.ts index 89b8a98..fb23775 100644 --- a/src/manifest/net/manifest-net-add-outbound.action.ts +++ b/src/manifest/net/manifest-net-add-outbound.action.ts @@ -4,6 +4,7 @@ import { ManifestCompManifestDto } from "../dto"; import { merge } from "lodash"; import { writeFile } from "fs/promises"; import { combineUniqueArrays } from "../../lib/data"; +import { assertFileExists } from "../../lib/file"; /** * Parse provided urls and report error if any of them are invalid. @@ -34,6 +35,8 @@ export async function manifestNetAddOutboundAction( urls: string[], options: ManifestNetAddOutboundOptions, ): Promise { + await assertFileExists("Manifest file", options.manifest, "Check --manifest option."); + const parsedUrls = parseUrls(urls); const protocols = parsedUrls.map((url) => url.protocol.replace(/:$/, "")); From 7b333a3e3870b82fd88de1393f2fc15e7c956c85 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Sep 2023 10:05:30 +0000 Subject: [PATCH 15/34] chore(deps-dev): bump eslint from 8.48.0 to 8.49.0 Bumps [eslint](https://github.com/eslint/eslint) from 8.48.0 to 8.49.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v8.48.0...v8.49.0) --- updated-dependencies: - dependency-name: eslint dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package-lock.json | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index 910c546..fae4db1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1100,9 +1100,9 @@ "dev": true }, "node_modules/@eslint/js": { - "version": "8.48.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.48.0.tgz", - "integrity": "sha512-ZSjtmelB7IJfWD2Fvb7+Z+ChTIKWq6kjda95fLcQKNS5aheVHn4IkfgRQE3sIIzTcSLwLcLZUD9UBt+V7+h+Pw==", + "version": "8.49.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.49.0.tgz", + "integrity": "sha512-1S8uAY/MTJqVx0SC4epBq+N2yhuwtNwLbJYNZyhL2pO1ZVKn5HFXav5T41Ryzy9K9V7ZId2JB2oy/W4aCd9/2w==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -1132,9 +1132,9 @@ } }, "node_modules/@humanwhocodes/config-array": { - "version": "0.11.10", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.10.tgz", - "integrity": "sha512-KVVjQmNUepDVGXNuoRRdmmEjruj0KfiGSbS8LVc12LMsWDQzRXJ0qdhN8L8uUigKpfEHRhlaQFY0ib1tnUbNeQ==", + "version": "0.11.11", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.11.tgz", + "integrity": "sha512-N2brEuAadi0CcdeMXUkhbZB84eskAc8MEX1By6qEchoVywSgXPIjou4rYsl0V3Hj0ZnuGycGCjdNgockbzeWNA==", "dev": true, "dependencies": { "@humanwhocodes/object-schema": "^1.2.1", @@ -4370,16 +4370,16 @@ } }, "node_modules/eslint": { - "version": "8.48.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.48.0.tgz", - "integrity": "sha512-sb6DLeIuRXxeM1YljSe1KEx9/YYeZFQWcV8Rq9HfigmdDEugjLEVEa1ozDjL6YDjBpQHPJxJzze+alxi4T3OLg==", + "version": "8.49.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.49.0.tgz", + "integrity": "sha512-jw03ENfm6VJI0jA9U+8H5zfl5b+FvuU3YYvZRdZHOlU2ggJkxrlkJH4HcDrZpj6YwD8kuYqvQM8LyesoazrSOQ==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", "@eslint/eslintrc": "^2.1.2", - "@eslint/js": "8.48.0", - "@humanwhocodes/config-array": "^0.11.10", + "@eslint/js": "8.49.0", + "@humanwhocodes/config-array": "^0.11.11", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", "ajv": "^6.12.4", From 2ba5126bd4114f8bea9e0b49d8f74034c877f496 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Sep 2023 10:07:30 +0000 Subject: [PATCH 16/34] chore(deps-dev): bump @types/lodash from 4.14.197 to 4.14.198 Bumps [@types/lodash](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/lodash) from 4.14.197 to 4.14.198. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/lodash) --- updated-dependencies: - dependency-name: "@types/lodash" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 910c546..def9ee3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2738,9 +2738,9 @@ "dev": true }, "node_modules/@types/lodash": { - "version": "4.14.197", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.197.tgz", - "integrity": "sha512-BMVOiWs0uNxHVlHBgzTIqJYmj+PgCo4euloGF+5m4okL3rEYzM2EEv78mw8zWSMM57dM7kVIgJ2QDvwHSoCI5g==", + "version": "4.14.198", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.198.tgz", + "integrity": "sha512-trNJ/vtMZYMLhfN45uLq4ShQSw0/S7xCTLLVM+WM1rmFpba/VS42jVUgaO3w/NOLiWR/09lnYk0yMaA/atdIsg==", "dev": true }, "node_modules/@types/luxon": { From df882fd01d5396254c9da1aeba31ab5471aadc33 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Sep 2023 10:08:17 +0000 Subject: [PATCH 17/34] chore(deps-dev): bump prettier from 3.0.2 to 3.0.3 Bumps [prettier](https://github.com/prettier/prettier) from 3.0.2 to 3.0.3. - [Release notes](https://github.com/prettier/prettier/releases) - [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md) - [Commits](https://github.com/prettier/prettier/compare/3.0.2...3.0.3) --- updated-dependencies: - dependency-name: prettier dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 910c546..88e2396 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10611,9 +10611,9 @@ } }, "node_modules/prettier": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.2.tgz", - "integrity": "sha512-o2YR9qtniXvwEZlOKbveKfDQVyqxbEIWn48Z8m3ZJjBjcCmUy3xZGIv+7AkaeuaTr6yPXJjwv07ZWlsWbEy1rQ==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.3.tgz", + "integrity": "sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==", "dev": true, "bin": { "prettier": "bin/prettier.cjs" From 8bc56c67bff022964f4f76bc3496c741c39addea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Grzywacz?= Date: Tue, 12 Sep 2023 13:18:06 +0200 Subject: [PATCH 18/34] docs: updated README.md according to best practices JST-393 JST-394 --- LICENSE | 165 ++++++++++++++++++++++++++++++++++++++++++++ README.md | 200 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 352 insertions(+), 13 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0a04128 --- /dev/null +++ b/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/README.md b/README.md index d37a903..0aa577d 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,201 @@ +![Logo of the project](https://raw.githubusercontent.com/jehna/readme-best-practices/master/sample-logo.png) + # Golem SDK CLI -## About +Golem SDK CLI is a companion tool for the [Golem SDK](https://github.com/golemfactory/golem-js). It allows you to create and manage Golem JS projects. + + +## Installing / Getting started + +Golem SDK CLI is available as a NPM package. + +Install using npm: +```shell +npm install -g @golem-sdk/cli +``` -Golem SDK CLI is a command line interface supporting development of applications using [Golem JS](https://github.com/golemfactory/golem-js) +Install using yarn: +```shell +yarn global add @golem-sdk/cli +``` -## Installation +To check if the installation was successful, run: +```shell +golem-sdk --version +``` -@golem-sdk/cli is available as a NPM package. +After installation the CLI is ready to be used. -You can install it through npm: +## Developing -```bash -npm install @golem-js/cli +If you want to install from source code or you would like to develop Golem SDK CLI, you can clone the repository and install dependencies: + +```shell +git clone git@github.com:golemfactory/golem-sdk-cli.git +cd golem-sdk-cli/ +npm install ``` -or by yarn: +### Building -```bash -yarn add @golem-js/cli +To build the CLI, run: +```shell +npm run build ``` -## Usage +To make the CLI available in your system, run: +```shell +npm link +``` + +Now `golem-sdk` command should be available in your system. + + +## Features + +Golem SDK CLI is a companion tool for the [Golem SDK](https://github.com/golemfactory/golem-js). As such, it is being +developed in parallel with the SDK and new features will be added as the SDK evolves or new use-cases are identified. + +If you see a feature missing, or a possible quality of life improvement we could implement, please open an issue or a pull request. + + +### Golem Manifest + +Golem Manifest is a JSON document that describes your Golem application. While it is not required for simple applications, +you will need it if you want to access advanced features of the Golem SDK. + +Whenever `golem-sdk` CLI needs to access the manifest file, by default it will look for `manifest.json`. If you want to use a different file, you can do that by using `--manifest` (or `-m`) option. -```bash -golem-sdk --help + +### Creating a Golem Manifest + +To create a new Golem Manifest with `golem-sdk` CLI, run: + +```shell +golem-sdk manifest create ``` + +If you have a `package.json` file in your project, it will be used to fill in the `name`, `version` and `description` fields of the manifest. Otherwise you wiil need to provide them manually. + +Provided `image` argument should identify the GVMI image that will be used by your application. + + +#### Image + +The manifest needs to contain the image URL pointing to GVMI download location and it's hash to validate its integrity. +In order to facilitate the process of creating a manifest, `golem-sdk` accepts multiple forms of image argument, where some of them will automatically resolve the URL and/or hash. +Please consult the table bellow for more details: + +| Argument | `--image-hash` | Example | Notes | +|------------------------------------|------------------------------|-----------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------| +| Image tag | automatically resolved | `golem/node:latest` | Image hash will be fetched from [https://registry.golem.network]. This is the recommended method. | +| Image hash | resolved from image argument | `3d6c48bb4c192708168d53cee4f36876b263b7745c3a3c239c6749cd` | Image URL will point to [https://registry.golem.network] | +| URL to registry.golem.network | automatically resolved | `https://registry.golem.network/v1/image/download?tag=golem-examples/blender:2.80&https=true` | | +| URL to arbitrary download location | hash is needed | `https://example.com/my-image` | | + +If hash is not provided or resolved, you will get a warning that the manifest will not be usable until you provide it manually. + + +### Adding outbound URLs + +In order to be able to access the internet from Golem network, your application needs to declare the outbound URLs it will be using inside its manifest. + +There is a default set of URLs that providers may allow your application to use (TODO: link to default URL whitelist). +In order to use URLs from outside of this whitelist, you need to provide a signed manifest that can be validated by certificates issued by Golem. + +**NOTE:** Currently there is no process for obtaining the certificate needed to validate the manifest signature. Please contact us on discord if you need to use URLs outside the default whitelist. + +You can use this command multiple times to update URLs in the manifest, and you can pass multiple URLs at once. + + +#### Example: Simple use + +This command will update the manifest file with the URL. + +```shell +golem-sdk manifest net add-outbound https://golem.network +``` + + +#### Example: Multiple URLs + +This command will update the manifest file with all the URLs provided. + +```shell +golem-sdk manifest net add-outbound https://golem.network https://github.com https://example.com +``` + +### Signing the manifest + +In order to use URLs outside the default whitelist, you need to sign the manifest with a key provided by Golem. + +**NOTE:** Currently there is no process for obtaining the certificate needed to validate the manifest signature. Please contact us on discord if you need to use URLs outside the default whitelist. + +If your private key is encrypted, you will need to provide the correct passphrase (`-p` or `--passphrase` option). + +To sign the manifest, run: +```shell +golem-sdk manifest sign -k +``` + +This command will produce a signature file (by default `manifest.sig`) that you will need to use in your application. + + +### Verifying the signature + +You can verify manifest signature with your certificate using the following command: + +```shell +golem-sdk manifest verify +``` + +By default, it will use `manifest.pem` as the certificate file and `manifest.sig` as the signature file. You can change that by using `--certificate-file` and `--signature-file` options. + +On success, it will print the following message: + +``` +Manifest matches signature. +``` + +It is important to use this command to make sure the key you are using is compatible with your certificate. + + +## Contributing + +If you'd like to contribute to the project, you can fork the repository and create a Pull Request. +Code contribution are warmly welcomed. + +Please make sure the code follows coding style as configured in `.eslintrc` and `.prettierrc`. + +The Pull Request should describe what changes you've made, what's the purpose of them and how to use them. + + +## Links + +- Project homepage: https://github.com/golemfactory/golem-sdk-cli +- Repository: https://github.com/golemfactory/golem-sdk-cli +- Issue tracker: https://github.com/golemfactory/golem-sdk-cli/issues + - In case of sensitive bugs like security vulnerabilities, please contact + my@email.com directly instead of using issue tracker. We value your effort + to improve the security and privacy of this project! +- [Golem](https://golem.network), a global, open-source, decentralized supercomputer that anyone can access. +- [Golem Image Registry](https://registry.golem.network) +- [Golem Discord](https://discord.gg/golem) +- Documentation: + - [Quick start](https://docs.golem.network/creators/javascript/quickstart/) for JavaScript developers + - Have a look at the most important concepts behind any Golem + application: [Golem application fundamentals](https://handbook.golem.network/requestor-tutorials/golem-application-fundamentals) + - Learn about preparing your own Docker-like images for + the [VM runtime](https://handbook.golem.network/requestor-tutorials/vm-runtime) + - [Requestor development: a quick primer](https://handbook.golem.network/requestor-tutorials/flash-tutorial-of-requestor-development) +- Related projects: + - [Golem SDK](https://github.com/golemfactory/golem-js) - Typescript + NodeJS API for Golem. + - [Yagna](https://github.com/golemfactory/yagna) - An open platform and marketplace for distributed computations. + - [yapapi](https://github.com/golemfactory/yapapi) - Python high-level API for Golem. + + +## Licensing + +The code in this project is licensed under LGPL-3 license. + +See [LICENSE](LICENSE) for more information. From da285f7a271295a61f7f09287136dbfae641ea66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Grzywacz?= Date: Tue, 12 Sep 2023 13:21:32 +0200 Subject: [PATCH 19/34] chore(dependabot): change target branch from master to beta --- .github/dependabot.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 3a3cce5..77c0a3c 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -7,5 +7,6 @@ version: 2 updates: - package-ecosystem: "npm" # See documentation for possible values directory: "/" # Location of package manifests + target-branch: "beta" schedule: interval: "weekly" From 04fd47b726cfc569d17d0895cf96f9457a95f0f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Grzywacz?= Date: Wed, 13 Sep 2023 06:22:37 +0200 Subject: [PATCH 20/34] docs: updated README.md according to best practices - PR requested fixes JST-393 JST-394 --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 0aa577d..44f1e8e 100644 --- a/README.md +++ b/README.md @@ -100,10 +100,10 @@ If hash is not provided or resolved, you will get a warning that the manifest wi In order to be able to access the internet from Golem network, your application needs to declare the outbound URLs it will be using inside its manifest. -There is a default set of URLs that providers may allow your application to use (TODO: link to default URL whitelist). +There is a default set of URLs that providers may allow your application to use ([default whitelist](https://github.com/golemfactory/ya-installer-resources/tree/main/whitelist)). In order to use URLs from outside of this whitelist, you need to provide a signed manifest that can be validated by certificates issued by Golem. -**NOTE:** Currently there is no process for obtaining the certificate needed to validate the manifest signature. Please contact us on discord if you need to use URLs outside the default whitelist. +**NOTE:** Currently there is no process for obtaining the certificate needed to validate the manifest signature. Please contact us on [Discord](https://chat.golem.network) if you need to use URLs outside the default whitelist. You can use this command multiple times to update URLs in the manifest, and you can pass multiple URLs at once. @@ -129,7 +129,7 @@ golem-sdk manifest net add-outbound https://golem.network https://github.com htt In order to use URLs outside the default whitelist, you need to sign the manifest with a key provided by Golem. -**NOTE:** Currently there is no process for obtaining the certificate needed to validate the manifest signature. Please contact us on discord if you need to use URLs outside the default whitelist. +**NOTE:** Currently there is no process for obtaining the certificate needed to validate the manifest signature. Please contact us on [Discord](https://chat.golem.network) if you need to use URLs outside the default whitelist. If your private key is encrypted, you will need to provide the correct passphrase (`-p` or `--passphrase` option). @@ -176,13 +176,13 @@ The Pull Request should describe what changes you've made, what's the purpose of - Repository: https://github.com/golemfactory/golem-sdk-cli - Issue tracker: https://github.com/golemfactory/golem-sdk-cli/issues - In case of sensitive bugs like security vulnerabilities, please contact - my@email.com directly instead of using issue tracker. We value your effort - to improve the security and privacy of this project! + us directly through our [contact form](https://www.golem.network/contact-form) instead of using issue tracker. + We value your effort to improve the security and privacy of this project! - [Golem](https://golem.network), a global, open-source, decentralized supercomputer that anyone can access. - [Golem Image Registry](https://registry.golem.network) -- [Golem Discord](https://discord.gg/golem) +- [Golem Discord](https://chat.golem.network) - Documentation: - - [Quick start](https://docs.golem.network/creators/javascript/quickstart/) for JavaScript developers + - [Quick start](https://docs.golem.network/docs/creators/javascript/quickstarts) for JavaScript developers - Have a look at the most important concepts behind any Golem application: [Golem application fundamentals](https://handbook.golem.network/requestor-tutorials/golem-application-fundamentals) - Learn about preparing your own Docker-like images for From f19bccb0079354e44123de2de348a93d271360db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Grzywacz?= Date: Wed, 13 Sep 2023 06:23:21 +0200 Subject: [PATCH 21/34] docs: updated README.md according to best practices - PR requested fixes JST-393 JST-394 --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 44f1e8e..e3ae2c8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ -![Logo of the project](https://raw.githubusercontent.com/jehna/readme-best-practices/master/sample-logo.png) - # Golem SDK CLI Golem SDK CLI is a companion tool for the [Golem SDK](https://github.com/golemfactory/golem-js). It allows you to create and manage Golem JS projects. From 61040be0b0c32341c042297a2ce9471e28d0ae84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Grzywacz?= Date: Wed, 13 Sep 2023 11:05:44 +0200 Subject: [PATCH 22/34] docs: updated README.md according to best practices - prettier fixes JST-393 JST-394 --- README.md | 46 ++++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index e3ae2c8..08f6fec 100644 --- a/README.md +++ b/README.md @@ -2,22 +2,24 @@ Golem SDK CLI is a companion tool for the [Golem SDK](https://github.com/golemfactory/golem-js). It allows you to create and manage Golem JS projects. - ## Installing / Getting started Golem SDK CLI is available as a NPM package. Install using npm: + ```shell npm install -g @golem-sdk/cli ``` Install using yarn: + ```shell yarn global add @golem-sdk/cli ``` To check if the installation was successful, run: + ```shell golem-sdk --version ``` @@ -37,18 +39,19 @@ npm install ### Building To build the CLI, run: + ```shell npm run build ``` To make the CLI available in your system, run: + ```shell npm link ``` Now `golem-sdk` command should be available in your system. - ## Features Golem SDK CLI is a companion tool for the [Golem SDK](https://github.com/golemfactory/golem-js). As such, it is being @@ -56,7 +59,6 @@ developed in parallel with the SDK and new features will be added as the SDK evo If you see a feature missing, or a possible quality of life improvement we could implement, please open an issue or a pull request. - ### Golem Manifest Golem Manifest is a JSON document that describes your Golem application. While it is not required for simple applications, @@ -64,7 +66,6 @@ you will need it if you want to access advanced features of the Golem SDK. Whenever `golem-sdk` CLI needs to access the manifest file, by default it will look for `manifest.json`. If you want to use a different file, you can do that by using `--manifest` (or `-m`) option. - ### Creating a Golem Manifest To create a new Golem Manifest with `golem-sdk` CLI, run: @@ -77,7 +78,6 @@ If you have a `package.json` file in your project, it will be used to fill in th Provided `image` argument should identify the GVMI image that will be used by your application. - #### Image The manifest needs to contain the image URL pointing to GVMI download location and it's hash to validate its integrity. @@ -85,7 +85,7 @@ In order to facilitate the process of creating a manifest, `golem-sdk` accepts m Please consult the table bellow for more details: | Argument | `--image-hash` | Example | Notes | -|------------------------------------|------------------------------|-----------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------| +| ---------------------------------- | ---------------------------- | --------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | | Image tag | automatically resolved | `golem/node:latest` | Image hash will be fetched from [https://registry.golem.network]. This is the recommended method. | | Image hash | resolved from image argument | `3d6c48bb4c192708168d53cee4f36876b263b7745c3a3c239c6749cd` | Image URL will point to [https://registry.golem.network] | | URL to registry.golem.network | automatically resolved | `https://registry.golem.network/v1/image/download?tag=golem-examples/blender:2.80&https=true` | | @@ -93,7 +93,6 @@ Please consult the table bellow for more details: If hash is not provided or resolved, you will get a warning that the manifest will not be usable until you provide it manually. - ### Adding outbound URLs In order to be able to access the internet from Golem network, your application needs to declare the outbound URLs it will be using inside its manifest. @@ -105,7 +104,6 @@ In order to use URLs from outside of this whitelist, you need to provide a signe You can use this command multiple times to update URLs in the manifest, and you can pass multiple URLs at once. - #### Example: Simple use This command will update the manifest file with the URL. @@ -114,7 +112,6 @@ This command will update the manifest file with the URL. golem-sdk manifest net add-outbound https://golem.network ``` - #### Example: Multiple URLs This command will update the manifest file with all the URLs provided. @@ -132,18 +129,18 @@ In order to use URLs outside the default whitelist, you need to sign the manifes If your private key is encrypted, you will need to provide the correct passphrase (`-p` or `--passphrase` option). To sign the manifest, run: + ```shell golem-sdk manifest sign -k ``` This command will produce a signature file (by default `manifest.sig`) that you will need to use in your application. - ### Verifying the signature You can verify manifest signature with your certificate using the following command: -```shell +```shell golem-sdk manifest verify ``` @@ -157,7 +154,6 @@ Manifest matches signature. It is important to use this command to make sure the key you are using is compatible with your certificate. - ## Contributing If you'd like to contribute to the project, you can fork the repository and create a Pull Request. @@ -167,30 +163,28 @@ Please make sure the code follows coding style as configured in `.eslintrc` and The Pull Request should describe what changes you've made, what's the purpose of them and how to use them. - ## Links - Project homepage: https://github.com/golemfactory/golem-sdk-cli - Repository: https://github.com/golemfactory/golem-sdk-cli - Issue tracker: https://github.com/golemfactory/golem-sdk-cli/issues - - In case of sensitive bugs like security vulnerabilities, please contact - us directly through our [contact form](https://www.golem.network/contact-form) instead of using issue tracker. - We value your effort to improve the security and privacy of this project! + - In case of sensitive bugs like security vulnerabilities, please contact + us directly through our [contact form](https://www.golem.network/contact-form) instead of using issue tracker. + We value your effort to improve the security and privacy of this project! - [Golem](https://golem.network), a global, open-source, decentralized supercomputer that anyone can access. - [Golem Image Registry](https://registry.golem.network) - [Golem Discord](https://chat.golem.network) - Documentation: - - [Quick start](https://docs.golem.network/docs/creators/javascript/quickstarts) for JavaScript developers - - Have a look at the most important concepts behind any Golem - application: [Golem application fundamentals](https://handbook.golem.network/requestor-tutorials/golem-application-fundamentals) - - Learn about preparing your own Docker-like images for - the [VM runtime](https://handbook.golem.network/requestor-tutorials/vm-runtime) - - [Requestor development: a quick primer](https://handbook.golem.network/requestor-tutorials/flash-tutorial-of-requestor-development) + - [Quick start](https://docs.golem.network/docs/creators/javascript/quickstarts) for JavaScript developers + - Have a look at the most important concepts behind any Golem + application: [Golem application fundamentals](https://handbook.golem.network/requestor-tutorials/golem-application-fundamentals) + - Learn about preparing your own Docker-like images for + the [VM runtime](https://handbook.golem.network/requestor-tutorials/vm-runtime) + - [Requestor development: a quick primer](https://handbook.golem.network/requestor-tutorials/flash-tutorial-of-requestor-development) - Related projects: - - [Golem SDK](https://github.com/golemfactory/golem-js) - Typescript + NodeJS API for Golem. - - [Yagna](https://github.com/golemfactory/yagna) - An open platform and marketplace for distributed computations. - - [yapapi](https://github.com/golemfactory/yapapi) - Python high-level API for Golem. - + - [Golem SDK](https://github.com/golemfactory/golem-js) - Typescript + NodeJS API for Golem. + - [Yagna](https://github.com/golemfactory/yagna) - An open platform and marketplace for distributed computations. + - [yapapi](https://github.com/golemfactory/yapapi) - Python high-level API for Golem. ## Licensing From 975e838b80e12fc7bdbf4c8e05f2dda0c7b90bba Mon Sep 17 00:00:00 2001 From: jalas167 <42438166+jalas167@users.noreply.github.com> Date: Wed, 13 Sep 2023 18:10:11 +0200 Subject: [PATCH 23/34] Update README.md --- README.md | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 08f6fec..12a7ab6 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Golem SDK CLI is a companion tool for the [Golem SDK](https://github.com/golemfa ## Installing / Getting started -Golem SDK CLI is available as a NPM package. +Golem SDK CLI is available as an NPM package. Install using npm: @@ -24,7 +24,7 @@ To check if the installation was successful, run: golem-sdk --version ``` -After installation the CLI is ready to be used. +After installation, the CLI is ready to be used. ## Developing @@ -55,16 +55,16 @@ Now `golem-sdk` command should be available in your system. ## Features Golem SDK CLI is a companion tool for the [Golem SDK](https://github.com/golemfactory/golem-js). As such, it is being -developed in parallel with the SDK and new features will be added as the SDK evolves or new use-cases are identified. +developed in parallel with the SDK and new features will be added as the SDK evolves or new use cases are identified. -If you see a feature missing, or a possible quality of life improvement we could implement, please open an issue or a pull request. +If you see a feature missing, or a possible quality-of-life improvement we could implement, please open an issue or a pull request. ### Golem Manifest Golem Manifest is a JSON document that describes your Golem application. While it is not required for simple applications, you will need it if you want to access advanced features of the Golem SDK. -Whenever `golem-sdk` CLI needs to access the manifest file, by default it will look for `manifest.json`. If you want to use a different file, you can do that by using `--manifest` (or `-m`) option. +Whenever the `golem-sdk` CLI needs to access the manifest file, by default it will look for `manifest.json`. If you want to use a different file, you can do that by using the `--manifest` (or `-m`) option. ### Creating a Golem Manifest @@ -74,15 +74,15 @@ To create a new Golem Manifest with `golem-sdk` CLI, run: golem-sdk manifest create ``` -If you have a `package.json` file in your project, it will be used to fill in the `name`, `version` and `description` fields of the manifest. Otherwise you wiil need to provide them manually. +If you have a `package.json` file in your project, it will be used to fill in the `name`, `version`, and `description` fields of the manifest. Otherwise, you will need to provide them manually. -Provided `image` argument should identify the GVMI image that will be used by your application. +The provided `image` argument should identify the GVMI image that will be used by your application. #### Image -The manifest needs to contain the image URL pointing to GVMI download location and it's hash to validate its integrity. -In order to facilitate the process of creating a manifest, `golem-sdk` accepts multiple forms of image argument, where some of them will automatically resolve the URL and/or hash. -Please consult the table bellow for more details: +The manifest needs to contain the image URL pointing to the GVMI download location and its hash to validate its integrity. +To facilitate the process of creating a manifest, `golem-sdk` accepts multiple forms of image argument, where some of them will automatically resolve the URL and/or hash. +Please consult the table below for more details: | Argument | `--image-hash` | Example | Notes | | ---------------------------------- | ---------------------------- | --------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | @@ -91,14 +91,14 @@ Please consult the table bellow for more details: | URL to registry.golem.network | automatically resolved | `https://registry.golem.network/v1/image/download?tag=golem-examples/blender:2.80&https=true` | | | URL to arbitrary download location | hash is needed | `https://example.com/my-image` | | -If hash is not provided or resolved, you will get a warning that the manifest will not be usable until you provide it manually. +If the hash is not provided or resolved, you will get a warning that the manifest will not be usable until you provide it manually. ### Adding outbound URLs -In order to be able to access the internet from Golem network, your application needs to declare the outbound URLs it will be using inside its manifest. +To be able to access the internet from the Golem network, your application needs to declare the outbound URLs it will be using inside its manifest. There is a default set of URLs that providers may allow your application to use ([default whitelist](https://github.com/golemfactory/ya-installer-resources/tree/main/whitelist)). -In order to use URLs from outside of this whitelist, you need to provide a signed manifest that can be validated by certificates issued by Golem. +To use URLs from outside of this whitelist, you need to provide a signed manifest that can be validated by certificates issued by Golem. **NOTE:** Currently there is no process for obtaining the certificate needed to validate the manifest signature. Please contact us on [Discord](https://chat.golem.network) if you need to use URLs outside the default whitelist. @@ -122,7 +122,7 @@ golem-sdk manifest net add-outbound https://golem.network https://github.com htt ### Signing the manifest -In order to use URLs outside the default whitelist, you need to sign the manifest with a key provided by Golem. +To use URLs outside the default whitelist, you need to sign the manifest with a key provided by Golem. **NOTE:** Currently there is no process for obtaining the certificate needed to validate the manifest signature. Please contact us on [Discord](https://chat.golem.network) if you need to use URLs outside the default whitelist. @@ -138,13 +138,13 @@ This command will produce a signature file (by default `manifest.sig`) that you ### Verifying the signature -You can verify manifest signature with your certificate using the following command: +You can verify the manifest signature with your certificate using the following command: ```shell golem-sdk manifest verify ``` -By default, it will use `manifest.pem` as the certificate file and `manifest.sig` as the signature file. You can change that by using `--certificate-file` and `--signature-file` options. +By default, it will use `manifest.pem` as the certificate file and `manifest.sig` as the signature file. You can change that by using the `--certificate-file` and `--signature-file` options. On success, it will print the following message: @@ -157,9 +157,9 @@ It is important to use this command to make sure the key you are using is compat ## Contributing If you'd like to contribute to the project, you can fork the repository and create a Pull Request. -Code contribution are warmly welcomed. +Code contributions are warmly welcomed. -Please make sure the code follows coding style as configured in `.eslintrc` and `.prettierrc`. +Please make sure the code follows the coding style as configured in `.eslintrc` and `.prettierrc`. The Pull Request should describe what changes you've made, what's the purpose of them and how to use them. @@ -169,18 +169,16 @@ The Pull Request should describe what changes you've made, what's the purpose of - Repository: https://github.com/golemfactory/golem-sdk-cli - Issue tracker: https://github.com/golemfactory/golem-sdk-cli/issues - In case of sensitive bugs like security vulnerabilities, please contact - us directly through our [contact form](https://www.golem.network/contact-form) instead of using issue tracker. + us directly through our [contact form](https://www.golem.network/contact-form) instead of using the issue tracker. We value your effort to improve the security and privacy of this project! - [Golem](https://golem.network), a global, open-source, decentralized supercomputer that anyone can access. - [Golem Image Registry](https://registry.golem.network) - [Golem Discord](https://chat.golem.network) - Documentation: - - [Quick start](https://docs.golem.network/docs/creators/javascript/quickstarts) for JavaScript developers + - [QuickStart](https://docs.golem.network/docs/creators/javascript/quickstarts) for JavaScript developers - Have a look at the most important concepts behind any Golem application: [Golem application fundamentals](https://handbook.golem.network/requestor-tutorials/golem-application-fundamentals) - - Learn about preparing your own Docker-like images for - the [VM runtime](https://handbook.golem.network/requestor-tutorials/vm-runtime) - - [Requestor development: a quick primer](https://handbook.golem.network/requestor-tutorials/flash-tutorial-of-requestor-development) + - Learn about preparing your own Docker-like [images]([https://handbook.golem.network/requestor-tutorials/vm-runtime](https://docs.golem.network/docs/creators/javascript/guides/golem-images)). - Related projects: - [Golem SDK](https://github.com/golemfactory/golem-js) - Typescript + NodeJS API for Golem. - [Yagna](https://github.com/golemfactory/yagna) - An open platform and marketplace for distributed computations. @@ -188,6 +186,6 @@ The Pull Request should describe what changes you've made, what's the purpose of ## Licensing -The code in this project is licensed under LGPL-3 license. +The code in this project is licensed under the LGPL-3 license. See [LICENSE](LICENSE) for more information. From 96ac3d4ffd129ce423a3529de5bd15d52b1210bb Mon Sep 17 00:00:00 2001 From: jalas167 <42438166+jalas167@users.noreply.github.com> Date: Wed, 13 Sep 2023 18:21:52 +0200 Subject: [PATCH 24/34] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 12a7ab6..a3be8f7 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ If you see a feature missing, or a possible quality-of-life improvement we could ### Golem Manifest -Golem Manifest is a JSON document that describes your Golem application. While it is not required for simple applications, +[Golem Manifest](https://docs.golem.network/docs/golem/payload-manifest) is a JSON document that describes your Golem application. While it is not required for simple applications, you will need it if you want to access advanced features of the Golem SDK. Whenever the `golem-sdk` CLI needs to access the manifest file, by default it will look for `manifest.json`. If you want to use a different file, you can do that by using the `--manifest` (or `-m`) option. @@ -76,7 +76,7 @@ golem-sdk manifest create If you have a `package.json` file in your project, it will be used to fill in the `name`, `version`, and `description` fields of the manifest. Otherwise, you will need to provide them manually. -The provided `image` argument should identify the GVMI image that will be used by your application. +The provided `image` argument should identify the GVMI image that will be used by your application. You cacn learn more about Golem images [here](https://docs.golem.network/docs/creators/javascript/guides/golem-images). #### Image @@ -178,7 +178,7 @@ The Pull Request should describe what changes you've made, what's the purpose of - [QuickStart](https://docs.golem.network/docs/creators/javascript/quickstarts) for JavaScript developers - Have a look at the most important concepts behind any Golem application: [Golem application fundamentals](https://handbook.golem.network/requestor-tutorials/golem-application-fundamentals) - - Learn about preparing your own Docker-like [images]([https://handbook.golem.network/requestor-tutorials/vm-runtime](https://docs.golem.network/docs/creators/javascript/guides/golem-images)). + - Learn about preparing your custom Docker-like [images](https://docs.golem.network/docs/creators/javascript/tutorials/building-custom-image). - Related projects: - [Golem SDK](https://github.com/golemfactory/golem-js) - Typescript + NodeJS API for Golem. - [Yagna](https://github.com/golemfactory/yagna) - An open platform and marketplace for distributed computations. From e6412bb9bd16b50c92f164fc20250b9e37746be1 Mon Sep 17 00:00:00 2001 From: pgrzy-golem <127095432+pgrzy-golem@users.noreply.github.com> Date: Thu, 14 Sep 2023 10:20:35 +0200 Subject: [PATCH 25/34] Bugfix/jst 415 (#29) fix: better image URL and hash validation in manifest create command fix: better URL error handling in manifest net add-outbound command JST-415 --- src/manifest/manifest-create.action.ts | 29 +++++++++++++++++-- src/manifest/manifest-create.command.ts | 5 +++- .../net/manifest-net-add-outbound.action.ts | 8 +++-- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/manifest/manifest-create.action.ts b/src/manifest/manifest-create.action.ts index 5ab76d2..c48bb9c 100644 --- a/src/manifest/manifest-create.action.ts +++ b/src/manifest/manifest-create.action.ts @@ -87,9 +87,17 @@ function getImageUrlFromHash(hash: string): ImageInfo { async function getImage(imageSpec: string, providedHash?: string): Promise { const tagRegex = /^(.*?)\/(.*?):(.*)$/; - const hashRegex = /^(\w+)$/; + const hashRegex = /^[a-z0-9]{56}$/; + const maybeHash = /^[a-z0-9]+$/; + + if (maybeHash.test(imageSpec)) { + if (!hashRegex.test(imageSpec)) { + console.error( + `Error: Image name ${imageSpec} looks like a hash, but has invalid length. Please make sure it is a valid SHA3 hash.`, + ); + process.exit(1); + } - if (hashRegex.test(imageSpec)) { return getImageUrlFromHash(imageSpec); } else if (tagRegex.test(imageSpec)) { return await getImageUrlFromTag(imageSpec, providedHash); @@ -164,8 +172,25 @@ async function fillOptionsWithPackageJson(options: ManifestCreateOptions): Promi return options; } +function validateImageInfo(imageInfo: ImageInfo) { + const hashWithFunctionRegEx = /^sha3:[a-z0-9]{56}$/; + + try { + new URL(imageInfo.url); + } catch (e) { + console.error(`Error: Failed to parse xx image URL ${imageInfo.url}: ${e}`); + process.exit(1); + } + + if (!hashWithFunctionRegEx.test(imageInfo.hash ?? "")) { + console.error(`Error: Invalid image hash ${imageInfo.hash}.`); + process.exit(1); + } +} + export async function manifestCreateAction(image: string, options: ManifestCreateOptions): Promise { const imageData = await getImage(image, options.imageHash); + validateImageInfo(imageData); const now = DateTime.now(); const expires = now.plus({ days: 90 }); // TODO: move that to options? diff --git a/src/manifest/manifest-create.command.ts b/src/manifest/manifest-create.command.ts index 1393c39..8492942 100644 --- a/src/manifest/manifest-create.command.ts +++ b/src/manifest/manifest-create.command.ts @@ -12,7 +12,10 @@ manifestCreateCommand .option("-v, --manifest-version ", "Version of the manifest.") .option("-i, --image-hash ", "Image hash to be used in the manifest (format 'hash-function:hash-base64').") .option("-p, --package-json ", "Package.json file to be used as information source.") - .argument("", "Image to be used in the manifest, identified by URL, image tag or image hash.") + .argument( + "", + "Image to be used in the manifest, identified by URL, image tag or image hash. See README.md for details.", + ) .addHelpText( "after", "\npackage.json can be used to automatically fill manifest name, description and version." + diff --git a/src/manifest/net/manifest-net-add-outbound.action.ts b/src/manifest/net/manifest-net-add-outbound.action.ts index fb23775..26d75e6 100644 --- a/src/manifest/net/manifest-net-add-outbound.action.ts +++ b/src/manifest/net/manifest-net-add-outbound.action.ts @@ -16,16 +16,18 @@ function parseUrls(urls: string[]): URL[] { urls.forEach((url) => { try { - parsed.push(new URL(url)); + const parsedUrl = new URL(url); + // TODO: Filter only supported protocols. Problem: we don't know yet what is supported. + parsed.push(parsedUrl); } catch (e) { errors.push(url); } }); if (errors.length) { - console.error("Invalid URLs:"); + console.error("Error: Invalid URLs provided:"); console.error(errors.map((url) => `- ${url}`).join("\n")); - throw new Error("Invalid URL(s) provided."); + process.exit(1); } return parsed; From 7a0c83721197716e8f7bbdea13bf238f5d65b430 Mon Sep 17 00:00:00 2001 From: jalas167 <42438166+jalas167@users.noreply.github.com> Date: Thu, 14 Sep 2023 11:25:07 +0200 Subject: [PATCH 26/34] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a3be8f7..aa00d71 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ golem-sdk manifest create If you have a `package.json` file in your project, it will be used to fill in the `name`, `version`, and `description` fields of the manifest. Otherwise, you will need to provide them manually. -The provided `image` argument should identify the GVMI image that will be used by your application. You cacn learn more about Golem images [here](https://docs.golem.network/docs/creators/javascript/guides/golem-images). +The provided `image` argument should identify the GVMI image that will be used by your application. You can learn more about Golem images [here](https://docs.golem.network/docs/creators/javascript/guides/golem-images). #### Image From c3b7416ab5be0283fd1176cd362058f6c831a52e Mon Sep 17 00:00:00 2001 From: jalas167 <42438166+jalas167@users.noreply.github.com> Date: Thu, 14 Sep 2023 12:51:46 +0200 Subject: [PATCH 27/34] Update README.md --- README.md | 46 +++++++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index aa00d71..47607b4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Golem SDK CLI -Golem SDK CLI is a companion tool for the [Golem SDK](https://github.com/golemfactory/golem-js). It allows you to create and manage Golem JS projects. +Golem SDK CLI is a companion tool for the [Golem SDK](https://github.com/golemfactory/golem-js). It accelerates the creation and management of Golem JS projects. ## Installing / Getting started @@ -57,26 +57,25 @@ Now `golem-sdk` command should be available in your system. Golem SDK CLI is a companion tool for the [Golem SDK](https://github.com/golemfactory/golem-js). As such, it is being developed in parallel with the SDK and new features will be added as the SDK evolves or new use cases are identified. -If you see a feature missing, or a possible quality-of-life improvement we could implement, please open an issue or a pull request. +If you see a feature missing or a possible JS SDK user experience improvement we could implement, please open an issue or a pull request. ### Golem Manifest -[Golem Manifest](https://docs.golem.network/docs/golem/payload-manifest) is a JSON document that describes your Golem application. While it is not required for simple applications, -you will need it if you want to access advanced features of the Golem SDK. +[Golem Manifest](https://docs.golem.network/docs/golem/payload-manifest) is a JSON document that describes your Golem application. While it is not necessary for simple applications, you will need it if you want to access advanced features of the Golem SDK, like access to the Internet (outbound). -Whenever the `golem-sdk` CLI needs to access the manifest file, by default it will look for `manifest.json`. If you want to use a different file, you can do that by using the `--manifest` (or `-m`) option. +The `golem-sdk` CLI allows users to create and update the manifest file. By default, it assumes the manifest is available in a `manifest.json` file in the current folder. If you want to point to a different file, use the --manifest (or -m) option. ### Creating a Golem Manifest To create a new Golem Manifest with `golem-sdk` CLI, run: ```shell -golem-sdk manifest create +golem-sdk manifest create [--image-hash hash] ``` -If you have a `package.json` file in your project, it will be used to fill in the `name`, `version`, and `description` fields of the manifest. Otherwise, you will need to provide them manually. +The `image` argument should identify the GVMI image used by your application. The tools accept a few formats which are explained in the table below. You can learn more about Golem images [here](https://docs.golem.network/docs/creators/javascript/guides/golem-images). -The provided `image` argument should identify the GVMI image that will be used by your application. You can learn more about Golem images [here](https://docs.golem.network/docs/creators/javascript/guides/golem-images). +If you have a `package.json` file in your project, the tool will use `name`, `version`, and `description` fields from this file to fill fields in the manifest. Otherwise, you will need to provide them manually. #### Image @@ -84,33 +83,29 @@ The manifest needs to contain the image URL pointing to the GVMI download locati To facilitate the process of creating a manifest, `golem-sdk` accepts multiple forms of image argument, where some of them will automatically resolve the URL and/or hash. Please consult the table below for more details: -| Argument | `--image-hash` | Example | Notes | -| ---------------------------------- | ---------------------------- | --------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | -| Image tag | automatically resolved | `golem/node:latest` | Image hash will be fetched from [https://registry.golem.network]. This is the recommended method. | -| Image hash | resolved from image argument | `3d6c48bb4c192708168d53cee4f36876b263b7745c3a3c239c6749cd` | Image URL will point to [https://registry.golem.network] | -| URL to registry.golem.network | automatically resolved | `https://registry.golem.network/v1/image/download?tag=golem-examples/blender:2.80&https=true` | | -| URL to arbitrary download location | hash is needed | `https://example.com/my-image` | | +| Argument format | Example | Is `--image-hash` required? | Notes | +| ---------------------------------- | ---------------------------- | ---------------------------------------------------------|-------------------------------------------- | +| Image tag | `golem/node:latest` | No, it will be automatically resolved. | Image hash is fetched from [https://registry.golem.network]. It is the recommended method. | +| Image hash | `3d6c48bb4c192708168d53cee4f36876b263b7745c3a3c239c6749cd`| No, it is resolved from the image argument. | Image URL will point to [https://registry.golem.network] | +| URL to registry.golem.network | `https://registry.golem.network/v1/image/download?tag=golem-examples/blender:2.80&https=true`| No, it is automatically resolved. | | +| URL to arbitrary download location | `https://example.com/my-image` | Yes, image-hash is required. | Image is calculated by the gvmkit-build conversion tool. | If the hash is not provided or resolved, you will get a warning that the manifest will not be usable until you provide it manually. ### Adding outbound URLs -To be able to access the internet from the Golem network, your application needs to declare the outbound URLs it will be using inside its manifest. +For your application to access the Internet from the Golem network, the manifest must include the outbound URLs the application will be using. -There is a default set of URLs that providers may allow your application to use ([default whitelist](https://github.com/golemfactory/ya-installer-resources/tree/main/whitelist)). -To use URLs from outside of this whitelist, you need to provide a signed manifest that can be validated by certificates issued by Golem. - -**NOTE:** Currently there is no process for obtaining the certificate needed to validate the manifest signature. Please contact us on [Discord](https://chat.golem.network) if you need to use URLs outside the default whitelist. - -You can use this command multiple times to update URLs in the manifest, and you can pass multiple URLs at once. +The default set of URLs that providers may allow your application to use is available ([here](https://github.com/golemfactory/ya-installer-resources/tree/main/whitelist)). Note providers can modify the content of the list. #### Example: Simple use -This command will update the manifest file with the URL. +This command will update the manifest file with the provided URL: ```shell golem-sdk manifest net add-outbound https://golem.network ``` +You can use this command multiple times to add additional URLs to the manifest or pass many URLs in a single run: #### Example: Multiple URLs @@ -122,11 +117,7 @@ golem-sdk manifest net add-outbound https://golem.network https://github.com htt ### Signing the manifest -To use URLs outside the default whitelist, you need to sign the manifest with a key provided by Golem. - -**NOTE:** Currently there is no process for obtaining the certificate needed to validate the manifest signature. Please contact us on [Discord](https://chat.golem.network) if you need to use URLs outside the default whitelist. - -If your private key is encrypted, you will need to provide the correct passphrase (`-p` or `--passphrase` option). +If the provider configured an audited-payload rule for URLs outside the whitelist, you can get access to such URLs, on the provision they are declared in the manifest, and the manifest is signed by the key linked with the certificate accepted by the provider. To sign the manifest, run: @@ -134,6 +125,7 @@ To sign the manifest, run: golem-sdk manifest sign -k ``` +If your private key is encrypted, you will need to provide the correct passphrase (`-p` or `--passphrase` option). This command will produce a signature file (by default `manifest.sig`) that you will need to use in your application. ### Verifying the signature From c6dcd4de9a8aaf82337a749e9de26c63a6aa776c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Grzywacz?= Date: Fri, 15 Sep 2023 06:47:14 +0200 Subject: [PATCH 28/34] docs: updated README.md according to best practices - changed license JST-393 --- LICENSE | 827 +++++++++++++++++++++++++++++++++++++--------- README.md | 4 +- package-lock.json | 2 +- package.json | 2 +- 4 files changed, 672 insertions(+), 163 deletions(-) diff --git a/LICENSE b/LICENSE index 0a04128..e72bfdd 100644 --- a/LICENSE +++ b/LICENSE @@ -1,165 +1,674 @@ - GNU LESSER GENERAL PUBLIC LICENSE + GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. \ No newline at end of file diff --git a/README.md b/README.md index 47607b4..b0f7392 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ Now `golem-sdk` command should be available in your system. Golem SDK CLI is a companion tool for the [Golem SDK](https://github.com/golemfactory/golem-js). As such, it is being developed in parallel with the SDK and new features will be added as the SDK evolves or new use cases are identified. -If you see a feature missing or a possible JS SDK user experience improvement we could implement, please open an issue or a pull request. +If you see a feature missing or a possible Golem SDK user experience improvement we could implement, please open an issue or a pull request. ### Golem Manifest @@ -178,6 +178,6 @@ The Pull Request should describe what changes you've made, what's the purpose of ## Licensing -The code in this project is licensed under the LGPL-3 license. +The code in this project is licensed under the GPL-3 license. See [LICENSE](LICENSE) for more information. diff --git a/package-lock.json b/package-lock.json index a8ea57b..d2cc9af 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,7 +7,7 @@ "": { "name": "@golem-sdk/cli", "version": "1.0.0", - "license": "LGPL-3.0", + "license": "GPL-3.0", "dependencies": { "ajv": "^8.12.0", "ajv-formats": "^2.1.1", diff --git a/package.json b/package.json index c115c9a..ad48f5f 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "dist" ], "author": "GolemFactory ", - "license": "LGPL-3.0", + "license": "GPL-3.0", "engines": { "node": ">=16.0.0" }, From 52033a5d08f8c7672d5bdf0ba904dadfc5a4ea45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Grzywacz?= Date: Fri, 15 Sep 2023 06:48:40 +0200 Subject: [PATCH 29/34] docs: updated README.md according to best practices - fixed formatting JST-393 --- README.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index b0f7392..59fc639 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ The `golem-sdk` CLI allows users to create and update the manifest file. By defa To create a new Golem Manifest with `golem-sdk` CLI, run: ```shell -golem-sdk manifest create [--image-hash hash] +golem-sdk manifest create [--image-hash hash] ``` The `image` argument should identify the GVMI image used by your application. The tools accept a few formats which are explained in the table below. You can learn more about Golem images [here](https://docs.golem.network/docs/creators/javascript/guides/golem-images). @@ -83,12 +83,12 @@ The manifest needs to contain the image URL pointing to the GVMI download locati To facilitate the process of creating a manifest, `golem-sdk` accepts multiple forms of image argument, where some of them will automatically resolve the URL and/or hash. Please consult the table below for more details: -| Argument format | Example | Is `--image-hash` required? | Notes | -| ---------------------------------- | ---------------------------- | ---------------------------------------------------------|-------------------------------------------- | -| Image tag | `golem/node:latest` | No, it will be automatically resolved. | Image hash is fetched from [https://registry.golem.network]. It is the recommended method. | -| Image hash | `3d6c48bb4c192708168d53cee4f36876b263b7745c3a3c239c6749cd`| No, it is resolved from the image argument. | Image URL will point to [https://registry.golem.network] | -| URL to registry.golem.network | `https://registry.golem.network/v1/image/download?tag=golem-examples/blender:2.80&https=true`| No, it is automatically resolved. | | -| URL to arbitrary download location | `https://example.com/my-image` | Yes, image-hash is required. | Image is calculated by the gvmkit-build conversion tool. | +| Argument format | Example | Is `--image-hash` required? | Notes | +| ---------------------------------- | --------------------------------------------------------------------------------------------- | ------------------------------------------- | ------------------------------------------------------------------------------------------ | +| Image tag | `golem/node:latest` | No, it will be automatically resolved. | Image hash is fetched from [https://registry.golem.network]. It is the recommended method. | +| Image hash | `3d6c48bb4c192708168d53cee4f36876b263b7745c3a3c239c6749cd` | No, it is resolved from the image argument. | Image URL will point to [https://registry.golem.network] | +| URL to registry.golem.network | `https://registry.golem.network/v1/image/download?tag=golem-examples/blender:2.80&https=true` | No, it is automatically resolved. | | +| URL to arbitrary download location | `https://example.com/my-image` | Yes, image-hash is required. | Image is calculated by the gvmkit-build conversion tool. | If the hash is not provided or resolved, you will get a warning that the manifest will not be usable until you provide it manually. @@ -105,6 +105,7 @@ This command will update the manifest file with the provided URL: ```shell golem-sdk manifest net add-outbound https://golem.network ``` + You can use this command multiple times to add additional URLs to the manifest or pass many URLs in a single run: #### Example: Multiple URLs @@ -117,7 +118,7 @@ golem-sdk manifest net add-outbound https://golem.network https://github.com htt ### Signing the manifest -If the provider configured an audited-payload rule for URLs outside the whitelist, you can get access to such URLs, on the provision they are declared in the manifest, and the manifest is signed by the key linked with the certificate accepted by the provider. +If the provider configured an audited-payload rule for URLs outside the whitelist, you can get access to such URLs, on the provision they are declared in the manifest, and the manifest is signed by the key linked with the certificate accepted by the provider. To sign the manifest, run: From 3316362af9b99d685b39eca5d3b6c704de545a0a Mon Sep 17 00:00:00 2001 From: Phillip Jensen <33448819+cryptobench@users.noreply.github.com> Date: Mon, 18 Sep 2023 09:26:44 +0200 Subject: [PATCH 30/34] docs: mini fix to the readme --- README.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 59fc639..7a81488 100644 --- a/README.md +++ b/README.md @@ -50,12 +50,11 @@ To make the CLI available in your system, run: npm link ``` -Now `golem-sdk` command should be available in your system. +Now, the `golem-sdk` command should be available in your system. ## Features -Golem SDK CLI is a companion tool for the [Golem SDK](https://github.com/golemfactory/golem-js). As such, it is being -developed in parallel with the SDK and new features will be added as the SDK evolves or new use cases are identified. +Golem SDK CLI is a companion tool for the [Golem SDK](https://github.com/golemfactory/golem-js). It is developed in parallel with the SDK, and new features are added as the SDK evolves or new use cases emerge If you see a feature missing or a possible Golem SDK user experience improvement we could implement, please open an issue or a pull request. @@ -67,7 +66,7 @@ The `golem-sdk` CLI allows users to create and update the manifest file. By defa ### Creating a Golem Manifest -To create a new Golem Manifest with `golem-sdk` CLI, run: +To create a new Golem Manifest with the `golem-sdk` CLI, run: ```shell golem-sdk manifest create [--image-hash hash] @@ -75,7 +74,7 @@ golem-sdk manifest create [--image-hash hash] The `image` argument should identify the GVMI image used by your application. The tools accept a few formats which are explained in the table below. You can learn more about Golem images [here](https://docs.golem.network/docs/creators/javascript/guides/golem-images). -If you have a `package.json` file in your project, the tool will use `name`, `version`, and `description` fields from this file to fill fields in the manifest. Otherwise, you will need to provide them manually. +If you have a `package.json` file in your project, the tool will use the `name`, `version`, and `description` fields from the file to fill in the fields in the manifest. Otherwise, you will need to provide them manually. #### Image @@ -118,7 +117,7 @@ golem-sdk manifest net add-outbound https://golem.network https://github.com htt ### Signing the manifest -If the provider configured an audited-payload rule for URLs outside the whitelist, you can get access to such URLs, on the provision they are declared in the manifest, and the manifest is signed by the key linked with the certificate accepted by the provider. +If the provider has set up an audited-payload rule for URLs not on the whitelist, you can gain access to these URLs. However, they must be declared in the manifest, and the manifest is signed by the key linked with the certificate accepted by the provider. To sign the manifest, run: From adddfc0912cec769c80a3100c3b7afb978627dcd Mon Sep 17 00:00:00 2001 From: pgrzy-golem <127095432+pgrzy-golem@users.noreply.github.com> Date: Mon, 18 Sep 2023 10:26:12 +0200 Subject: [PATCH 31/34] fix: error handling when image is not found by tag (#30) * fix: error handling when image is not found by tag JST-416 --- src/manifest/manifest-create.action.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/manifest/manifest-create.action.ts b/src/manifest/manifest-create.action.ts index c48bb9c..93a84fd 100644 --- a/src/manifest/manifest-create.action.ts +++ b/src/manifest/manifest-create.action.ts @@ -18,10 +18,11 @@ async function resolveTaskPackageUrl(tag: string): Promise { const response = await fetch(url); if (response.status === 404) { - // TODO: Print url on debug and stop using exceptions. - throw new Error(`Error: Image ${tag} not found.`); + console.error(`Error: Image ${tag} not found in image registry.`); + process.exit(1); } else if (response.status != 200) { - throw Error(`Failed to fetch image information: ${response.status} ${response.statusText}`); + console.error(`Error: Failed to fetch image information of ${tag} from image registry: ${response.statusText}`); + process.exit(1); } const data = (await response.json()) as { https: string; http: string; sha3: string }; @@ -178,7 +179,7 @@ function validateImageInfo(imageInfo: ImageInfo) { try { new URL(imageInfo.url); } catch (e) { - console.error(`Error: Failed to parse xx image URL ${imageInfo.url}: ${e}`); + console.error(`Error: Failed to parse image URL ${imageInfo.url}: ${e}`); process.exit(1); } From b0edd79e805b40eff1a4e7c5f511a35117551df3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Sep 2023 09:36:46 +0000 Subject: [PATCH 32/34] chore(deps-dev): bump @typescript-eslint/parser from 6.4.1 to 6.7.0 Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 6.4.1 to 6.7.0. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.7.0/packages/parser) --- updated-dependencies: - dependency-name: "@typescript-eslint/parser" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package-lock.json | 88 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 81 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 910c546..cce7348 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2854,15 +2854,15 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "6.4.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.4.1.tgz", - "integrity": "sha512-610G6KHymg9V7EqOaNBMtD1GgpAmGROsmfHJPXNLCU9bfIuLrkdOygltK784F6Crboyd5tBFayPB7Sf0McrQwg==", + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.7.0.tgz", + "integrity": "sha512-jZKYwqNpNm5kzPVP5z1JXAuxjtl2uG+5NpaMocFPTNC2EdYIgbXIPImObOkhbONxtFTTdoZstLZefbaK+wXZng==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "6.4.1", - "@typescript-eslint/types": "6.4.1", - "@typescript-eslint/typescript-estree": "6.4.1", - "@typescript-eslint/visitor-keys": "6.4.1", + "@typescript-eslint/scope-manager": "6.7.0", + "@typescript-eslint/types": "6.7.0", + "@typescript-eslint/typescript-estree": "6.7.0", + "@typescript-eslint/visitor-keys": "6.7.0", "debug": "^4.3.4" }, "engines": { @@ -2881,6 +2881,80 @@ } } }, + "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/scope-manager": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.7.0.tgz", + "integrity": "sha512-lAT1Uau20lQyjoLUQ5FUMSX/dS07qux9rYd5FGzKz/Kf8W8ccuvMyldb8hadHdK/qOI7aikvQWqulnEq2nCEYA==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.7.0", + "@typescript-eslint/visitor-keys": "6.7.0" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/types": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.7.0.tgz", + "integrity": "sha512-ihPfvOp7pOcN/ysoj0RpBPOx3HQTJTrIN8UZK+WFd3/iDeFHHqeyYxa4hQk4rMhsz9H9mXpR61IzwlBVGXtl9Q==", + "dev": true, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/typescript-estree": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.7.0.tgz", + "integrity": "sha512-dPvkXj3n6e9yd/0LfojNU8VMUGHWiLuBZvbM6V6QYD+2qxqInE7J+J/ieY2iGwR9ivf/R/haWGkIj04WVUeiSQ==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.7.0", + "@typescript-eslint/visitor-keys": "6.7.0", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/visitor-keys": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.7.0.tgz", + "integrity": "sha512-/C1RVgKFDmGMcVGeD8HjKv2bd72oI1KxQDeY8uc66gw9R0OK0eMq48cA+jv9/2Ag6cdrsUGySm1yzYmfz0hxwQ==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.7.0", + "eslint-visitor-keys": "^3.4.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, "node_modules/@typescript-eslint/scope-manager": { "version": "6.4.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.4.1.tgz", From 9e0cd48adcd687d8d5e0665b38cf43708f9f3c35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Grzywacz?= Date: Tue, 19 Sep 2023 08:28:09 +0200 Subject: [PATCH 33/34] feat(new app command): implemented new app creation command from templates JST-424 --- .gitignore | 5 +- .npmignore | 6 + data/project-templates/js-node/package.json | 25 +++ data/project-templates/js-node/src/index.js | 39 +++++ package-lock.json | 23 ++- package.json | 4 +- src/main.ts | 3 +- src/new/new.action.ts | 171 ++++++++++++++++++++ src/new/new.command.ts | 20 +++ src/new/new.options.ts | 11 ++ 10 files changed, 300 insertions(+), 7 deletions(-) create mode 100644 .npmignore create mode 100644 data/project-templates/js-node/package.json create mode 100644 data/project-templates/js-node/src/index.js create mode 100644 src/new/new.action.ts create mode 100644 src/new/new.command.ts create mode 100644 src/new/new.options.ts diff --git a/.gitignore b/.gitignore index a70c47e..ca2e733 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,7 @@ dist/ .DS_Store manifest.json -*.sig \ No newline at end of file +*.sig + +data/project-templates/**/package-lock.json +data/project-templates/**/node_modules diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..ad30dac --- /dev/null +++ b/.npmignore @@ -0,0 +1,6 @@ +.* +tsconfig.json +node_modules/ +data/**/package-lock.json +data/**/node_modules/ +src/ diff --git a/data/project-templates/js-node/package.json b/data/project-templates/js-node/package.json new file mode 100644 index 0000000..80cffee --- /dev/null +++ b/data/project-templates/js-node/package.json @@ -0,0 +1,25 @@ +{ + "name": "nodejs-golem-app", + "version": "1.0.0", + "description": "NodeJS script using Go", + "main": "src/index.js", + "type": "module", + "scripts": { + "run": "node src/index.js", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "keywords": [ + "golem", + "network", + "application" + ], + "dependencies": { + "@golem-sdk/golem-js": "^0.11.2", + "dotenv": "^16.3.1" + }, + "devDependencies": { + "@golem-sdk/cli": "^1.0.0-beta.1" + } +} diff --git a/data/project-templates/js-node/src/index.js b/data/project-templates/js-node/src/index.js new file mode 100644 index 0000000..d45ac05 --- /dev/null +++ b/data/project-templates/js-node/src/index.js @@ -0,0 +1,39 @@ +import * as dotenv from "dotenv"; +import { LogLevel, ProposalFilters, TaskExecutor } from "@golem-sdk/golem-js"; + +dotenv.config(); + +(async function main() { + const executor = await TaskExecutor.create({ + // What do you want to run + package: "golem/node:20-alpine", + + // How much you wish to spend + budget: 0.5, + proposalFilter: ProposalFilters.limitPriceFilter({ + start: 0.1, + cpuPerSec: 0.1 / 3600, + envPerSec: 0.1 / 3600, + }), + + // Where you want to spend + payment: { + network: "polygon", + }, + + // Control the execution of tasks + maxTaskRetries: 0, + + // Useful for debugging + logLevel: LogLevel.Info, + taskTimeout: 5 * 60 * 1000, + }); + + try { + // Your code goes here + } catch (err) { + console.error("Running the task on Golem failed due to", err); + } finally { + await executor.end(); + } +})(); diff --git a/package-lock.json b/package-lock.json index d2cc9af..07aba31 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "ajv": "^8.12.0", "ajv-formats": "^2.1.1", "commander": "^11.0.0", + "enquirer": "^2.4.1", "lodash": "^4.17.21", "luxon": "^3.4.3", "new-find-package-json": "^2.0.0", @@ -3072,6 +3073,14 @@ } } }, + "node_modules/ansi-colors": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", + "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==", + "engines": { + "node": ">=6" + } + }, "node_modules/ansi-escapes": { "version": "4.3.2", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", @@ -3103,7 +3112,6 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, "engines": { "node": ">=8" } @@ -4089,6 +4097,18 @@ "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "dev": true }, + "node_modules/enquirer": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.4.1.tgz", + "integrity": "sha512-rRqJg/6gd538VHvR3PSrdRBb/1Vy2YfzHqzvbhGIQpDRKIa4FgV/54b5Q1xYSxOOwKvjXweS26E0Q+nAMwp2pQ==", + "dependencies": { + "ansi-colors": "^4.1.1", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8.6" + } + }, "node_modules/env-ci": { "version": "9.1.1", "resolved": "https://registry.npmjs.org/env-ci/-/env-ci-9.1.1.tgz", @@ -11512,7 +11532,6 @@ "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, "dependencies": { "ansi-regex": "^5.0.1" }, diff --git a/package.json b/package.json index ad48f5f..aca95b6 100644 --- a/package.json +++ b/package.json @@ -34,9 +34,6 @@ "marketplace", "cli" ], - "files": [ - "dist" - ], "author": "GolemFactory ", "license": "GPL-3.0", "engines": { @@ -46,6 +43,7 @@ "ajv": "^8.12.0", "ajv-formats": "^2.1.1", "commander": "^11.0.0", + "enquirer": "^2.4.1", "lodash": "^4.17.21", "luxon": "^3.4.3", "new-find-package-json": "^2.0.0", diff --git a/src/main.ts b/src/main.ts index 0cd12fc..334d7b1 100755 --- a/src/main.ts +++ b/src/main.ts @@ -2,6 +2,7 @@ import { Command } from "commander"; import { version } from "./lib/version"; import { manifestCommand } from "./manifest/manifest.command"; +import { newCommand } from "./new/new.command"; const program = new Command("golem-sdk"); program.version(version); @@ -10,6 +11,6 @@ program.version(version); // chalk.level = 0; // }); -program.addCommand(manifestCommand); +program.addCommand(manifestCommand).addCommand(newCommand); program.parse(); diff --git a/src/new/new.action.ts b/src/new/new.action.ts new file mode 100644 index 0000000..c37d3c0 --- /dev/null +++ b/src/new/new.action.ts @@ -0,0 +1,171 @@ +import { NewOptions, newProjectNameError, newProjectNameRegEx } from "./new.options"; + +import { prompt } from "enquirer"; +import { join } from "path"; +import { existsSync } from "fs"; +import { cp, readFile, writeFile } from "fs/promises"; + +async function getName(providedName: string): Promise { + if (!providedName) { + const result = (await prompt({ + type: "input", + name: "name", + message: "Project name", + validate(value: string) { + return !newProjectNameRegEx.test(value) ? newProjectNameError : true; + }, + })) as { name: string }; + + providedName = result.name; + } else { + if (!newProjectNameRegEx.test(providedName)) { + console.error(`Error: Project name ${providedName} is invalid: ${newProjectNameError}`); + process.exit(1); + } + } + + return providedName; +} + +async function getVersion(providedVersion?: string): Promise { + if (typeof providedVersion === "string") { + return providedVersion; + } + + const result = (await prompt({ + type: "input", + name: "version", + message: "Project version", + initial: "1.0.0", + })) as { version: string }; + + return result.version; +} + +async function getTemplate(providedTemplate?: string): Promise { + if (typeof providedTemplate !== "string") { + const result = (await prompt({ + type: "select", + name: "template", + message: "Select a project template", + choices: [ + { name: "js-node", hint: "Plain Javascript CLI application" }, + // { name: "js-webapp", hint: "Plain Javascript Express based web application" }, + ], + })) as { template: string }; + + providedTemplate = result.template; + } + + if (!newProjectNameRegEx.test(providedTemplate)) { + console.error(`Error: Template name ${providedTemplate} is invalid.`); + process.exit(1); + } + + return providedTemplate; +} + +async function getDescription(providedDescription?: string): Promise { + if (typeof providedDescription === "string") { + return providedDescription; + } + + const result = (await prompt({ + type: "input", + name: "description", + message: "Project description", + initial: "An unique and awesome application that runs on Golem Network", + })) as { description: string }; + + return result.description; +} + +type PackageJsonBasic = { + name: string; + description: string; + version: string; + author?: string; +}; + +async function updatePackageJson(projectPath: string, data: PackageJsonBasic): Promise { + const packageJson = join(projectPath, "package.json"); + let input: string; + let json: PackageJsonBasic; + + try { + input = await readFile(packageJson, "utf8"); + } catch (e) { + console.error(`Error: Failed to read ${packageJson}: ${e}`); + process.exit(1); + } + + try { + json = JSON.parse(input); + } catch (e) { + console.error(`Error: Failed to parse ${packageJson}: ${e}`); + process.exit(1); + } + + json.name = data.name; + json.description = data.description; + json.version = data.version; + if (data.author) { + json.author = data.author; + } + + try { + await writeFile(packageJson, JSON.stringify(json, null, 2)); + } catch (e) { + console.error(`Error: Failed to write ${packageJson}: ${e}`); + process.exit(1); + } +} + +export async function newAction(providedName: string, options: NewOptions) { + const name = await getName(providedName); + const projectPath = options.path ?? join(process.cwd(), name); + if (existsSync(projectPath)) { + console.error(`Error: ${projectPath} already exists.`); + process.exit(1); + } + + const template = await getTemplate(options.template); + const templatePath = join(__dirname, "../../data/project-templates", template); + if (!existsSync(templatePath)) { + console.error(`Error: Template ${template} not found.`); + process.exit(1); + } + + const description = await getDescription(options.description); + const version = await getVersion(options.version); + const author = options.author; + + console.log(`Creating a new Golem app in ${projectPath}.`); + + try { + await cp(templatePath, projectPath, { recursive: true }); + } catch (e) { + console.error(`Error: Failed to copy template files: ${e}`); + process.exit(1); + } + + // Update package.json + await updatePackageJson(projectPath, { + name, + description, + version, + author, + }); + + // TODO: Consider running npm install (or yarn, or whatever). + + console.log(`Project created successfully in ${projectPath}.`); + + if (!process.env.YAGNA_APPKEY) { + console.log( + "NOTE: You do not seem to have YAGNA_APPKEY environment variable defined. You will need to define it or provide a .env file with it to run your new appplication.", + ); + } + + // TODO: Show some next steps, or pull it from template directory. +} diff --git a/src/new/new.command.ts b/src/new/new.command.ts new file mode 100644 index 0000000..f00e69a --- /dev/null +++ b/src/new/new.command.ts @@ -0,0 +1,20 @@ +import { Command } from "commander"; +import { NewOptions } from "./new.options"; + +export const newCommand = new Command("new"); + +newCommand + .summary("Create new Golem project.") + .description("Create a new Golem project from template.") + .option("-p, --path ", "Path of the new project.") + .option("-t, --template