Compare commits
3 Commits
v0.0.1
...
v0.1.0-dev
Author | SHA1 | Date |
---|---|---|
semantic-release-bot | fceb7e1987 | |
Derrick Hammer | c914ed92d9 | |
Derrick Hammer | 65f3dcca6f |
|
@ -0,0 +1,13 @@
|
|||
name: Build/Publish
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
- develop-*
|
||||
|
||||
jobs:
|
||||
main:
|
||||
uses: lumeweb/github-node-deploy-workflow/.github/workflows/main.yml@master
|
||||
secrets: inherit
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"preset": [
|
||||
"@lumeweb/node-library-preset"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
# [0.1.0-develop.1](https://git.lumeweb.com/LumeWeb/publish-kernel-module/compare/v0.0.1...v0.1.0-develop.1) (2023-06-26)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* initial version ([65f3dcc](https://git.lumeweb.com/LumeWeb/publish-kernel-module/commit/65f3dcca6fe2cb3d65be7e4dc11e529f1bf06370))
|
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) <year> <copyright holders>
|
||||
Copyright (c) 2023 Hammer Technologies LLC
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
"name": "@lumeweb/publish-kernel-module",
|
||||
"version": "0.1.0-develop.1",
|
||||
"type": "module",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "gitea@git.lumeweb.com:LumeWeb/publish-kernel-module.git"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@lumeweb/node-library-preset": "git+https://git.lumeweb.com/LumeWeb/node-library-preset.git",
|
||||
"@types/prompts": "^2.4.4",
|
||||
"presetter": "*"
|
||||
},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"scripts": {
|
||||
"prepare": "presetter bootstrap",
|
||||
"build": "run build",
|
||||
"semantic-release": "semantic-release"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"files": [
|
||||
"lib/**"
|
||||
],
|
||||
"dependencies": {
|
||||
"@lumeweb/community-portals": "^0.1.0-develop.4",
|
||||
"@lumeweb/libportal": "^0.2.0-develop.9",
|
||||
"@lumeweb/libweb": "^0.2.0-develop.19",
|
||||
"chalk": "^5.2.0",
|
||||
"prompts": "^2.4.2"
|
||||
},
|
||||
"bin": "./lib/index.js"
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
#! /usr/bin/env node
|
||||
|
||||
import prompts from "prompts";
|
||||
import * as process from "process";
|
||||
import fs from "fs/promises";
|
||||
import path from "path";
|
||||
import {
|
||||
hexToBytes,
|
||||
maybeInitDefaultPortals,
|
||||
setActivePortalMasterKey,
|
||||
uploadObject,
|
||||
} from "@lumeweb/libweb";
|
||||
import chalk from "chalk";
|
||||
import * as util from "util";
|
||||
import { fileExists } from "#util.js";
|
||||
|
||||
let key = process.env.PORTAL_PRIVATE_KEY;
|
||||
|
||||
if (!key) {
|
||||
// @ts-ignore
|
||||
key = await prompts.prompts.password({
|
||||
name: "private_key",
|
||||
message: "Enter your private key",
|
||||
validate: (prev) => prev && prev.length === 64,
|
||||
});
|
||||
}
|
||||
|
||||
let file = process.env.KERNEL_FILE;
|
||||
|
||||
if (!file || !(await fileExists(file))) {
|
||||
const cwd = process.cwd();
|
||||
|
||||
const locations = [
|
||||
"dist/module.js",
|
||||
"dist/index.js",
|
||||
"lib/module.js",
|
||||
"lib/index.js",
|
||||
];
|
||||
|
||||
const promises = locations.map((item) => {
|
||||
item = path.join(cwd, item);
|
||||
return [item, fileExists(item)];
|
||||
});
|
||||
|
||||
const pResults: boolean[] = await Promise.all(
|
||||
promises.map((item) => item[1] as Promise<boolean>),
|
||||
);
|
||||
const results = pResults.reduce((prev, cur, index) => {
|
||||
if (cur) {
|
||||
prev.push(locations[index]);
|
||||
}
|
||||
|
||||
return prev;
|
||||
}, [] as any);
|
||||
|
||||
if (!results.length) {
|
||||
console.error("Kernel module could not be found");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
file = results[0];
|
||||
}
|
||||
|
||||
setActivePortalMasterKey(hexToBytes(key as string));
|
||||
maybeInitDefaultPortals();
|
||||
|
||||
const fd = await fs.open(file as string);
|
||||
|
||||
const [cid, err] = await uploadObject(
|
||||
fd.createReadStream(),
|
||||
BigInt((await fd.stat()).size),
|
||||
);
|
||||
|
||||
if (err) {
|
||||
console.error("Failed to publish: ", err);
|
||||
}
|
||||
|
||||
console.log(
|
||||
util.format(
|
||||
"%s: %s",
|
||||
chalk.green("Kernel module successfully published"),
|
||||
cid,
|
||||
),
|
||||
);
|
|
@ -0,0 +1,11 @@
|
|||
import fs from "fs/promises";
|
||||
|
||||
export async function fileExists(path: string) {
|
||||
try {
|
||||
await fs.stat(path);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
Loading…
Reference in New Issue