Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: read version from package.json and used source and out dirs #13

Merged
merged 3 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ dist/
.vscode/
.DS_Store

manifest.json
manifest.json
*.sig
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 3 additions & 1 deletion src/lib/version.ts
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 2 additions & 0 deletions src/manifest/manifest-create.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 2 additions & 0 deletions src/manifest/manifest-sign.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
18 changes: 10 additions & 8 deletions src/manifest/manifest-verify.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,16 @@ 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);
Expand All @@ -33,12 +42,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',
}));
*/
}
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
}
},
"compilerOptions": {
"outDir": "dist",
"outDir": "dist/",
"rootDir": "src/",
"experimentalDecorators": true,
"resolveJsonModule": true,
"moduleResolution": "node16"
Expand Down