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: v1.3 #11

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
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
50 changes: 50 additions & 0 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Pre-Release NPM

on:
push:
tags:
- '!v*'
- 'v*-rc*'
- 'v*-alpha*'
- 'v*-beta*'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: '14.x'
registry-url: 'https://registry.npmjs.org'

- name: Setup npm cache
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Install dependencies
run: npm ci

- name: Run build script
run: npm run build

- name: Publish package to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access public --tag beta

- name: Create GitHub release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: true
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
push:
tags:
- 'v*'
- '!v*-rc*'
- '!v*-alpha*'
- '!v*-beta*'

jobs:
build:
Expand Down
105 changes: 68 additions & 37 deletions package-lock.json

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

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@flybywiresim/igniter",
"version": "1.2.3",
"version": "2.0.0-alpha.1",
"types": "dist/index.d.ts",
"description": "An intelligent task runner written in Typescript.",
"repository": {
Expand All @@ -14,13 +14,17 @@
"lint": "eslint --ext .ts ./",
"test": "jest"
},
"dependencies": {
"cli-progress": "^3.12.0"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^17.1.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^11.2.0",
"@rollup/plugin-typescript": "^8.2.0",
"@types/jest": "^26.0.20",
"@types/mkdirp": "^1.0.1",
"@types/cli-progress": "^3.11.3",
"@typescript-eslint/eslint-plugin": "^4.15.0",
"@wessberg/rollup-plugin-ts": "^1.3.8",
"chalk": "^4.1.0",
Expand Down
4 changes: 2 additions & 2 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ export default [
file: './dist/binary.mjs',
},
plugins: [
typescript(),
typescript({ exclude: ["node_modules/**/*.json"] }),
nodeResolve(),
commonjs(),
json(),
shebang({ include: 'dist/binary.mjs' }),
],
},
{
input: 'src/Library/Index.ts',
input: 'src/Library/index.ts',
output: {
file: './dist/index.mjs',
},
Expand Down
27 changes: 18 additions & 9 deletions src/Binary.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import { Command } from 'commander';
import { Pool } from 'task-pool';
import os from 'os';
import { findConfigPath, loadConfigTask } from './Helpers';
import { Context } from './Library/Contracts/Context';
import { version } from '../package.json';
import Renderer from './Renderer';
import Cache from './Cache';
import { TaskOfTasks } from './Library';
import Renderer from './Renderer';

const binary = (new Command()).version(version)
.option('-c, --config <filename>', 'set the configuration file name', 'igniter.config.mjs')
.option('-j, --num-workers <number>', 'set the maximum number of workers to use', `${Number.MAX_SAFE_INTEGER}`)
.option('-j, --num-workers <number>', 'set the maximum number of workers to use', `${os.cpus().length}`)
.option('-r, --regex <regex>', 'regular expression used to filter tasks')
.option('-i, --invert', 'if true, regex will be used to reject tasks')
.option('--no-cache', 'do not skip tasks, even if hash matches cache')
.option('--no-tty', 'do not show updating output, just show a single render')
.option('-n, --no-cache', 'do not skip tasks, even if hash matches cache')
.option('-y, --no-tty', 'do not show updating output, just show a single render')
.option('-d, --dry-run', 'skip all tasks to show configuration')
.option('--debug', 'stop when an exception is thrown and show trace')
.parse(process.argv);
Expand All @@ -26,7 +28,10 @@ const context: Context = {
dryRun: options.dryRun,
filterRegex: options.regex ? RegExp(options.regex) : undefined,
invertRegex: options.invert,
taskPool: new Pool({ limit: options.numWorkers, timeout: 120000 }),
taskPool: new Pool({ limit: options.numWorkers, timeout: 120_000 }),
numWorkers: options.numWorkers,
showNestedTaskKeys: true,
isTTY: process.stdout.isTTY,
};

// Create and register a cache if needed.
Expand All @@ -36,11 +41,15 @@ if (options.cache) context.cache = new Cache(context);
const configRootTask = await loadConfigTask(context);

// Set up root task (and thus children) to use our context.
configRootTask.useContext(context);
configRootTask.useContext(context, null);

// Run and Render the config root task.
// If we have tty, render every 100ms, other perform single render.
await Renderer(configRootTask, options.tty ? 100 : 0);

const rootTaskCompletionCallback = Renderer.render(context, configRootTask as TaskOfTasks);

configRootTask.run().finally(() => rootTaskCompletionCallback());

// Export the new cache.
if (context.cache) context.cache.export();
if (context.cache) {
context.cache.export();
}
2 changes: 1 addition & 1 deletion src/Cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default class Cache implements CacheContract {
/**
* Get the value for a given key in the cache.
*/
get(key: string): string {
get(key: string): string | undefined {
return this.map.get(key);
}

Expand Down
Loading
Loading