Skip to content

Commit

Permalink
feat: update to conform with fbl@1.15.0 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
vlad-tkachenko committed Jan 22, 2021
1 parent 4a9eec4 commit 5330921
Show file tree
Hide file tree
Showing 18 changed files with 1,039 additions and 3,328 deletions.
140 changes: 0 additions & 140 deletions .circleci/config.yml

This file was deleted.

47 changes: 47 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Public NPM Package

on:
release:
types: [created]

jobs:
build_and_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '14.x'

- run: yarn install
- run: yarn docker:test

# send test coverage
- run: bash <(curl -s https://codecov.io/bash) -f ./coverage/coverage.lcov

- uses: actions/upload-artifact@v2
with:
name: coverage
path: ./coverage/

- uses: actions/upload-artifact@v2
with:
name: mochawesome-report
path: ./mochawesome-report/

build_and_publish:
needs: [build_and_test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '14.x'
registry-url: 'https://registry.npmjs.org'
- run: yarn install
- run: yarn build
- run: yarn install --prod

- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
31 changes: 31 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Tests

on:
push:
branches:
- develop

jobs:
build_and_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '14.x'

- run: yarn install
- run: yarn docker:test

# send test coverage
- run: bash <(curl -s https://codecov.io/bash) -f ./coverage/coverage.lcov

- uses: actions/upload-artifact@v2
with:
name: coverage
path: ./coverage/

- uses: actions/upload-artifact@v2
with:
name: mochawesome-report
path: ./mochawesome-report/
40 changes: 19 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,50 +15,48 @@
"docker:test": "rimraf coverage/ && rimraf .nyc_output/ && rimraf mochawesome-report/ && docker-compose up --build --abort-on-container-exit",
"build": "rimraf ./dist/ && tsc",
"lint": "tslint -c tslint.json src/**/*.ts test/**/*.ts index.ts",
"prettify": "prettier src/**/*.{md,ts,json} test/**/*.{md,ts,json} index.{md,ts,json} --write --config .prettierrc.yml && tslint 'src/**/*.ts' 'test/**/*.ts' 'index.ts' --fix",
"prepublishOnly": "npm run build && npm run lint"
"prettify": "prettier src/**/*.{md,ts,json} test/**/*.{md,ts,json} index.{md,ts,json} --write --config .prettierrc.yml && tslint 'src/**/*.ts' 'test/**/*.ts' 'index.ts' --fix"
},
"author": "FireBlink LTD",
"license": "MIT",
"dependencies": {
"glob": "7.1.6",
"joi": "17.2.1",
"js-yaml": "3.14.0",
"typedi": "0.8.0"
"joi": "17.3.0",
"js-yaml": "4.0.0"
},
"peerDependencies": {
"fbl": ">=1.14.0 <2.0.0"
},
"devDependencies": {
"@commitlint/cli": "9.1.2",
"@commitlint/config-conventional": "9.1.2",
"@commitlint/cli": "11.0.0",
"@commitlint/config-conventional": "11.0.0",
"@fireblink/k8s-api-client": "1.2.0",
"@types/chai": "4.2.12",
"@types/chai": "4.2.14",
"@types/form-data": "2.5.0",
"@types/glob": "7.1.3",
"@types/joi": "14.3.4",
"@types/js-yaml": "3.12.5",
"@types/node": "14.6.4",
"@types/joi": "17.2.3",
"@types/js-yaml": "4.0.0",
"@types/node": "14.14.22",
"chai": "4.2.0",
"chai-as-promised": "7.1.1",
"commitizen": "4.2.1",
"conventional-changelog-cli": "2.1.0",
"commitizen": "4.2.3",
"conventional-changelog-cli": "2.1.1",
"cz-conventional-changelog": "3.3.0",
"fbl": "1.14.0",
"husky": "4.2.5",
"fbl": "1.15.0",
"husky": "4.3.8",
"jsonlint": "1.6.3",
"lint-staged": "10.3.0",
"mocha": "8.1.3",
"lint-staged": "10.5.3",
"mocha": "8.2.1",
"mocha-typescript": "1.1.17",
"mochawesome": "6.1.1",
"mochawesome": "6.2.1",
"nyc": "15.1.0",
"prettier": "2.1.1",
"prettier": "2.2.1",
"rimraf": "3.0.2",
"source-map-support": "0.5.19",
"ts-node": "9.0.0",
"ts-node": "9.1.1",
"tslint": "6.1.3",
"tslint-config-prettier": "1.18.0",
"typescript": "4.0.2",
"typescript": "4.1.3",
"yarn-check": "0.0.3"
},
"nyc": {
Expand Down
3 changes: 1 addition & 2 deletions src/processors/ApplyActionProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as Joi from 'joi';
import { BaseActionProcessor } from './BaseActionProcessor';
import { K8sObjectJoiValidationSchema } from '../joi/K8sObjectJoiValidationSchema';
import { TempPathsRegistry } from 'fbl';
import Container from 'typedi';

export class ApplyActionProcessor extends BaseActionProcessor {
private static validationSchema = Joi.object({
Expand Down Expand Up @@ -50,7 +49,7 @@ export class ApplyActionProcessor extends BaseActionProcessor {
this.pushWithValue(args, '-n', this.options.namespace);

if (this.options.paths && this.options.paths.length) {
const tempPathsRegistry = Container.get(TempPathsRegistry);
const tempPathsRegistry = TempPathsRegistry.instance;
const targetDir = await tempPathsRegistry.createTempDir();
args.push('-R', '-f', targetDir);

Expand Down
17 changes: 7 additions & 10 deletions src/processors/BaseActionProcessor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ActionProcessor, ChildProcessService, FSUtil, FlowService, TempPathsRegistry, ContextUtil } from 'fbl';
import Container from 'typedi';
import { safeLoadAll, dump } from 'js-yaml';
import { loadAll, dump } from 'js-yaml';
import { promisify } from 'util';
import { writeFile } from 'fs';
import { createHash } from 'crypto';
Expand All @@ -23,7 +22,7 @@ export abstract class BaseActionProcessor extends ActionProcessor {
stdout: string;
stderr: string;
}> {
const childProcessService = Container.get(ChildProcessService);
const childProcessService = ChildProcessService.instance;

const stdout: string[] = [];
const stderr: string[] = [];
Expand Down Expand Up @@ -110,7 +109,7 @@ export abstract class BaseActionProcessor extends ActionProcessor {
* @returns temp file path
*/
protected async writeStringToTempFile(data: string): Promise<string> {
const tempPathsRegistry = Container.get(TempPathsRegistry);
const tempPathsRegistry = TempPathsRegistry.instance;
const filePath = await tempPathsRegistry.createTempFile(false, '.yaml');
await writeFileAsync(filePath, data, 'utf8');

Expand All @@ -134,9 +133,7 @@ export abstract class BaseActionProcessor extends ActionProcessor {
}

private getHash(path: string): string {
return createHash('sha256')
.update(path, 'utf8')
.digest('hex');
return createHash('sha256').update(path, 'utf8').digest('hex');
}

/**
Expand Down Expand Up @@ -165,7 +162,7 @@ export abstract class BaseActionProcessor extends ActionProcessor {
}

protected async processTemplateFile(sourcePath: string, targetPath: string): Promise<void> {
const flowService = Container.get(FlowService);
const flowService = FlowService.instance;

const absolutePath = FSUtil.getAbsolutePath(sourcePath, this.snapshot.wd);
let fileContent: string = await FSUtil.readTextFile(absolutePath);
Expand All @@ -183,7 +180,7 @@ export abstract class BaseActionProcessor extends ActionProcessor {
this.parameters,
);

const raw = safeLoadAll(fileContent);
const raw = loadAll(fileContent);
const docs = [];
for (const doc of raw) {
// resolve local template
Expand All @@ -204,7 +201,7 @@ export abstract class BaseActionProcessor extends ActionProcessor {
if (docs.length === 1) {
await writeFileAsync(targetPath, dump(docs[0]), 'utf8');
} else {
await writeFileAsync(targetPath, '---\n' + docs.map(d => dump(d)).join('\n---\n'), 'utf8');
await writeFileAsync(targetPath, '---\n' + docs.map((d) => dump(d)).join('\n---\n'), 'utf8');
}
}
}
3 changes: 1 addition & 2 deletions src/processors/CreateActionProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as Joi from 'joi';
import { BaseActionProcessor } from './BaseActionProcessor';
import { K8sObjectJoiValidationSchema } from '../joi/K8sObjectJoiValidationSchema';
import { TempPathsRegistry } from 'fbl';
import Container from 'typedi';

export class CreateActionProcessor extends BaseActionProcessor {
private static validationSchema = Joi.object({
Expand Down Expand Up @@ -50,7 +49,7 @@ export class CreateActionProcessor extends BaseActionProcessor {
this.pushWithValue(args, '-n', this.options.namespace);

if (this.options.paths && this.options.paths.length) {
const tempPathsRegistry = Container.get(TempPathsRegistry);
const tempPathsRegistry = TempPathsRegistry.instance;
const targetDir = await tempPathsRegistry.createTempDir();
args.push('-R', '-f', targetDir);

Expand Down
Loading

0 comments on commit 5330921

Please sign in to comment.