Skip to content

Commit

Permalink
Merge pull request #7 from kratos-mc/release/pre-built
Browse files Browse the repository at this point in the history
Release a new version `1.1.0-pre`
  • Loading branch information
PlayerNguyen authored Feb 21, 2023
2 parents 929435c + 525dec0 commit 2a12816
Show file tree
Hide file tree
Showing 10 changed files with 718 additions and 46 deletions.
1 change: 1 addition & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
node-version: 14
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm run build
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKENS }}
166 changes: 132 additions & 34 deletions package-lock.json

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

10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "kratos-api-engine",
"version": "1.0.0",
"version": "1.1.0-pre1",
"description": "",
"main": "./dist/index.js",
"scripts": {
"build": "tsc",
"build": "npm run clean && tsc",
"test": "mocha .",
"coverage": "nyc npm run test"
"coverage": "nyc npm run test",
"clean": "node ./scripts/rm-scripts.js ./dist"
},
"repository": {
"type": "git",
Expand All @@ -32,7 +33,8 @@
"mocha": "^10.2.0",
"nyc": "^15.1.0",
"ts-node": "^10.9.1",
"typescript": "^4.9.5"
"typescript": "^4.9.5",
"yargs": "^17.6.2"
},
"dependencies": {
"fs-extra": "^11.1.0",
Expand Down
18 changes: 18 additions & 0 deletions scripts/rm-scripts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const fse = require("fs-extra");
const { hideBin } = require("yargs/helpers");

const shortenArgv = hideBin(process.argv);
if (shortenArgv.length === 0) {
throw new Error(`Directory has not provided, using ./rm-scripts <path>`);
}

const willRemoveDirectory = shortenArgv[0];
if (fse.existsSync(willRemoveDirectory)) {
// Empty the directory
fse.emptyDirSync(willRemoveDirectory);
fse.rmSync(willRemoveDirectory, { force: true, recursive: true });

console.log(`Eliminated ${willRemoveDirectory}`);
} else {
console.log(`warn: not found ${willRemoveDirectory}`);
}
39 changes: 39 additions & 0 deletions src/Asset.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { AssetIndexContent } from "./Version";
import needle, { NeedleOptions } from "needle";

/**
* A reference that point to the asset json file.
* Asset json file contains all asset item references to download.
*
*/
export interface AssetIndexReference {
/**
* The id of the asset.
*/
id: string;
/**
* Checksum as sha1 for the asset json file.
*/
sha1: string;
/**
* File size of the json reference.
*/
size: number;
/**
* Total file size for all assets inside the reference after downloaded.
*/
totalSize: number;
/**
* Url that point to json file.
*/
url: string;
}

export async function getAssetIndexFromReference(
reference: AssetIndexReference,
options?: NeedleOptions
): Promise<AssetIndexContent> {
const response = await needle("get", reference.url, options);

return response.body;
}
4 changes: 3 additions & 1 deletion src/Index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as Manifest from "./Manifest";
import * as Version from "./Version";
import * as Asset from "./Asset";

export { Manifest };
export { Manifest, Version, Asset };
Loading

0 comments on commit 2a12816

Please sign in to comment.