@bitblit/ratchet-node-only 4.0.99-alpha → 4.0.102-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{types/build → build}/ratchet-node-only-info.d.ts +1 -1
- package/dist/{types/ci → ci}/apply-ci-env-variables-to-files.d.ts +1 -5
- package/dist/{es/ci → ci}/apply-ci-env-variables-to-files.js +5 -2
- package/dist/ci/apply-ci-env-variables-to-files.spec.js +23 -0
- package/dist/{types/ci → ci}/ci-run-information-util.d.ts +1 -1
- package/dist/{es/ci → ci}/ci-run-information-util.js +3 -3
- package/dist/ci/ci-run-information.js +1 -0
- package/dist/{types/cli → cli}/abstract-ratchet-cli-handler.d.ts +1 -1
- package/dist/{es/cli → cli}/abstract-ratchet-cli-handler.js +1 -1
- package/dist/{types/cli → cli}/ratchet-cli-handler.d.ts +2 -2
- package/dist/{es/cli → cli}/ratchet-cli-handler.js +5 -5
- package/dist/{types/csv → csv}/csv-ratchet.d.ts +1 -1
- package/dist/{es/csv → csv}/csv-ratchet.js +3 -3
- package/dist/csv/csv-ratchet.spec.d.ts +4 -0
- package/dist/csv/csv-ratchet.spec.js +41 -0
- package/dist/{types/files → files}/files-to-static-class.d.ts +0 -4
- package/dist/{es/files → files}/files-to-static-class.js +2 -2
- package/dist/files/files-to-static-class.spec.d.ts +1 -0
- package/dist/files/files-to-static-class.spec.js +11 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/{es/third-party → third-party}/git/git-ratchet.js +5 -4
- package/dist/third-party/git/git-ratchet.spec.d.ts +1 -0
- package/dist/third-party/git/git-ratchet.spec.js +9 -0
- package/dist/{types/third-party → third-party}/slack/publish-ci-release-to-slack.d.ts +0 -4
- package/dist/{es/third-party → third-party}/slack/publish-ci-release-to-slack.js +3 -2
- package/dist/third-party/slack/publish-ci-release-to-slack.spec.d.ts +1 -0
- package/dist/third-party/slack/publish-ci-release-to-slack.spec.js +24 -0
- package/package.json +8 -10
- package/dist/cjs/build/ratchet-node-only-info.js +0 -18
- package/dist/cjs/ci/apply-ci-env-variables-to-files.js +0 -82
- package/dist/cjs/ci/ci-run-information-util.js +0 -47
- package/dist/cjs/ci/ci-run-information.js +0 -2
- package/dist/cjs/cli/abstract-ratchet-cli-handler.js +0 -32
- package/dist/cjs/cli/cli-ratchet.js +0 -33
- package/dist/cjs/cli/ratchet-cli-handler.js +0 -21
- package/dist/cjs/csv/csv-ratchet.js +0 -163
- package/dist/cjs/files/files-to-static-class.js +0 -61
- package/dist/cjs/index.js +0 -14
- package/dist/cjs/third-party/git/git-ratchet.js +0 -74
- package/dist/cjs/third-party/slack/publish-ci-release-to-slack.js +0 -64
- package/dist/es/index.js +0 -11
- package/dist/tsconfig.cjs.tsbuildinfo +0 -1
- package/dist/tsconfig.es.tsbuildinfo +0 -1
- package/dist/tsconfig.types.tsbuildinfo +0 -1
- package/dist/types/index.d.ts +0 -14
- /package/dist/{es/build → build}/ratchet-node-only-info.js +0 -0
- /package/dist/{es/ci/ci-run-information.js → ci/apply-ci-env-variables-to-files.spec.d.ts} +0 -0
- /package/dist/{types/ci → ci}/ci-run-information.d.ts +0 -0
- /package/dist/{types/cli → cli}/cli-ratchet.d.ts +0 -0
- /package/dist/{es/cli → cli}/cli-ratchet.js +0 -0
- /package/dist/{types/third-party → third-party}/git/git-ratchet.d.ts +0 -0
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import { CiRunInformation } from './ci-run-information';
|
|
1
|
+
import { CiRunInformation } from './ci-run-information.js';
|
|
2
2
|
export declare class ApplyCiEnvVariablesToFiles {
|
|
3
3
|
static process(fileNames: string[], cfg: CiRunInformation, buildFinder?: string, branchFinder?: string, hashFinder?: string, tagFinder?: string, timeFinder?: string): Promise<number>;
|
|
4
4
|
static extractFileNames(): string[];
|
|
5
5
|
static extractVariableConfig(inName: string): CiRunInformation;
|
|
6
|
-
/**
|
|
7
|
-
And, in case you are running this command line...
|
|
8
|
-
TODO: should use switches to allow setting the various non-filename params
|
|
9
|
-
**/
|
|
10
6
|
static runFromCliArgs(args: string[]): Promise<number>;
|
|
11
7
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
-
import { ErrorRatchet
|
|
3
|
-
import {
|
|
2
|
+
import { ErrorRatchet } from '@bitblit/ratchet-common/dist/lang/error-ratchet.js';
|
|
3
|
+
import { Logger } from '@bitblit/ratchet-common/dist/logger/logger.js';
|
|
4
|
+
import { RequireRatchet } from '@bitblit/ratchet-common/dist/lang/require-ratchet.js';
|
|
5
|
+
import { StringRatchet } from '@bitblit/ratchet-common/dist/lang/string-ratchet.js';
|
|
6
|
+
import { CiRunInformationUtil } from './ci-run-information-util.js';
|
|
4
7
|
export class ApplyCiEnvVariablesToFiles {
|
|
5
8
|
static async process(fileNames, cfg, buildFinder = 'LOCAL-SNAPSHOT', branchFinder = 'LOCAL-BRANCH', hashFinder = 'LOCAL-HASH', tagFinder = 'LOCAL-TAG', timeFinder = 'LOCAL-TIME') {
|
|
6
9
|
RequireRatchet.notNullOrUndefined(cfg, 'cfg');
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ApplyCiEnvVariablesToFiles } from './apply-ci-env-variables-to-files.js';
|
|
2
|
+
import { Logger } from '@bitblit/ratchet-common/dist/logger/logger.js';
|
|
3
|
+
import { GlobalRatchet } from '@bitblit/ratchet-common/dist/lang/global-ratchet.js';
|
|
4
|
+
import { CiRunInformationUtil } from './ci-run-information-util.js';
|
|
5
|
+
describe('#applyCiEnvVariablesToFiles', function () {
|
|
6
|
+
xit('should fail if not in a ci environment', async () => {
|
|
7
|
+
try {
|
|
8
|
+
const result = await ApplyCiEnvVariablesToFiles.process(['test1.txt'], CiRunInformationUtil.createDefaultCircleCiRunInformation());
|
|
9
|
+
this.bail();
|
|
10
|
+
}
|
|
11
|
+
catch (err) {
|
|
12
|
+
Logger.debug('Caught expected error : %s', err['message']);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
it('should not fail if in a ci environment', async () => {
|
|
16
|
+
GlobalRatchet.setGlobalVar('CIRCLE_BUILD_NUM', '1');
|
|
17
|
+
GlobalRatchet.setGlobalVar('CIRCLE_BRANCH', 'B');
|
|
18
|
+
GlobalRatchet.setGlobalVar('CIRCLE_TAG', 'T');
|
|
19
|
+
GlobalRatchet.setGlobalVar('CIRCLE_SHA1', 'S');
|
|
20
|
+
const result = await ApplyCiEnvVariablesToFiles.process([], CiRunInformationUtil.createDefaultCircleCiRunInformation());
|
|
21
|
+
expect(result).toEqual(0);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { DateTime } from 'luxon';
|
|
2
|
-
import { GlobalRatchet } from '@bitblit/ratchet-common';
|
|
2
|
+
import { GlobalRatchet } from '@bitblit/ratchet-common/dist/lang/global-ratchet.js';
|
|
3
3
|
export class CiRunInformationUtil {
|
|
4
|
+
static DEFAULT_TIME_FORMAT = 'yyyy-MM-dd HH:mm:ss a z';
|
|
5
|
+
static DEFAULT_TIME_ZONE = 'America/Los_Angeles';
|
|
4
6
|
static createTestingCiRunInformation(timezone = CiRunInformationUtil.DEFAULT_TIME_ZONE) {
|
|
5
7
|
const now = new Date().toISOString();
|
|
6
8
|
const rval = {
|
|
@@ -39,5 +41,3 @@ export class CiRunInformationUtil {
|
|
|
39
41
|
return rval;
|
|
40
42
|
}
|
|
41
43
|
}
|
|
42
|
-
CiRunInformationUtil.DEFAULT_TIME_FORMAT = 'yyyy-MM-dd HH:mm:ss a z';
|
|
43
|
-
CiRunInformationUtil.DEFAULT_TIME_ZONE = 'America/Los_Angeles';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BuildInformation } from '@bitblit/ratchet-common';
|
|
1
|
+
import { BuildInformation } from '@bitblit/ratchet-common/dist/build/build-information.js';
|
|
2
2
|
export declare abstract class AbstractRatchetCliHandler {
|
|
3
3
|
abstract fetchHandlerMap(): Record<string, any>;
|
|
4
4
|
abstract fetchVersionInfo(): BuildInformation;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BuildInformation } from '@bitblit/ratchet-common/dist/
|
|
2
|
-
import { AbstractRatchetCliHandler } from './abstract-ratchet-cli-handler';
|
|
1
|
+
import { BuildInformation } from '@bitblit/ratchet-common/dist/build/build-information.js';
|
|
2
|
+
import { AbstractRatchetCliHandler } from './abstract-ratchet-cli-handler.js';
|
|
3
3
|
export declare class RatchetCliHandler extends AbstractRatchetCliHandler {
|
|
4
4
|
fetchHandlerMap(): Record<string, any>;
|
|
5
5
|
fetchVersionInfo(): BuildInformation;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { RatchetNodeOnlyInfo } from '../build/ratchet-node-only-info';
|
|
2
|
-
import { ApplyCiEnvVariablesToFiles } from '../ci/apply-ci-env-variables-to-files';
|
|
3
|
-
import { FilesToStaticClass } from '../files/files-to-static-class';
|
|
4
|
-
import { PublishCiReleaseToSlack } from '../third-party/slack/publish-ci-release-to-slack';
|
|
5
|
-
import { AbstractRatchetCliHandler } from './abstract-ratchet-cli-handler';
|
|
1
|
+
import { RatchetNodeOnlyInfo } from '../build/ratchet-node-only-info.js';
|
|
2
|
+
import { ApplyCiEnvVariablesToFiles } from '../ci/apply-ci-env-variables-to-files.js';
|
|
3
|
+
import { FilesToStaticClass } from '../files/files-to-static-class.js';
|
|
4
|
+
import { PublishCiReleaseToSlack } from '../third-party/slack/publish-ci-release-to-slack.js';
|
|
5
|
+
import { AbstractRatchetCliHandler } from './abstract-ratchet-cli-handler.js';
|
|
6
6
|
export class RatchetCliHandler extends AbstractRatchetCliHandler {
|
|
7
7
|
fetchHandlerMap() {
|
|
8
8
|
return {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import { parse } from 'csv-parse';
|
|
3
|
-
import { Logger } from '@bitblit/ratchet-common';
|
|
3
|
+
import { Logger } from '@bitblit/ratchet-common/dist/logger/logger.js';
|
|
4
|
+
import { RequireRatchet } from '@bitblit/ratchet-common/dist/lang/require-ratchet.js';
|
|
5
|
+
import { MapRatchet } from '@bitblit/ratchet-common/dist/lang/map-ratchet.js';
|
|
4
6
|
import { stringify } from 'csv-stringify';
|
|
5
|
-
import { RequireRatchet } from '@bitblit/ratchet-common';
|
|
6
|
-
import { MapRatchet } from '@bitblit/ratchet-common';
|
|
7
7
|
import { Readable } from 'stream';
|
|
8
8
|
export class CsvRatchet {
|
|
9
9
|
static defaultParseOptions() {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Subject } from 'rxjs';
|
|
2
|
+
import { StringWritable } from '@bitblit/ratchet-common/dist/stream/string-writable.js';
|
|
3
|
+
import { CsvRatchet } from './csv-ratchet.js';
|
|
4
|
+
import { Logger } from '@bitblit/ratchet-common/dist/logger/logger.js';
|
|
5
|
+
import { PromiseRatchet } from '@bitblit/ratchet-common/dist/lang/promise-ratchet.js';
|
|
6
|
+
describe('#streamObjectsToCsv', function () {
|
|
7
|
+
it('should parse a string', async () => {
|
|
8
|
+
const testString = 'a,b\n1,2\n3,4\n';
|
|
9
|
+
const out = await CsvRatchet.stringParse(testString, (CsvRatchet.defaultParseFunction));
|
|
10
|
+
expect(out).toBeTruthy();
|
|
11
|
+
expect(out.length).toEqual(2);
|
|
12
|
+
expect(out[0].a).toEqual('1');
|
|
13
|
+
expect(out[1].a).toEqual('3');
|
|
14
|
+
});
|
|
15
|
+
it('should generate csv data', async () => {
|
|
16
|
+
const output = [
|
|
17
|
+
{ a: 1, b: '2' },
|
|
18
|
+
{ a: 3, b: '4' },
|
|
19
|
+
];
|
|
20
|
+
const testString = await CsvRatchet.generateCsvData(output);
|
|
21
|
+
expect(testString).toBeTruthy();
|
|
22
|
+
expect(testString.length).toBeGreaterThan(10);
|
|
23
|
+
});
|
|
24
|
+
it('should stream objects to a csv', async () => {
|
|
25
|
+
const sub = new Subject();
|
|
26
|
+
const out = new StringWritable();
|
|
27
|
+
const prom = CsvRatchet.streamObjectsToCsv(sub, out);
|
|
28
|
+
for (let i = 1; i < 6; i++) {
|
|
29
|
+
Logger.debug('Proc : %d', i);
|
|
30
|
+
sub.next({ a: i, b: 'test ' + i + ' ,,' });
|
|
31
|
+
await PromiseRatchet.wait(10);
|
|
32
|
+
}
|
|
33
|
+
sub.complete();
|
|
34
|
+
Logger.debug('Waiting on write');
|
|
35
|
+
const result = await prom;
|
|
36
|
+
Logger.debug('Write complete');
|
|
37
|
+
const val = out.value;
|
|
38
|
+
expect(result).toEqual(5);
|
|
39
|
+
Logger.debug('Have res : %d and val : \n%s', result, val);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
export declare class FilesToStaticClass {
|
|
2
2
|
static process(fileNames: string[], outClassName: string, outFileName?: string): Promise<string>;
|
|
3
|
-
/**
|
|
4
|
-
And, in case you are running this command line...
|
|
5
|
-
TODO: should use switches to allow setting the various non-filename params
|
|
6
|
-
**/
|
|
7
3
|
static runFromCliArgs(args: string[]): Promise<string>;
|
|
8
4
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Logger } from '@bitblit/ratchet-common';
|
|
1
|
+
import { Logger } from '@bitblit/ratchet-common/dist/logger/logger.js';
|
|
2
2
|
import fs from 'fs';
|
|
3
|
-
import { CliRatchet } from '../cli/cli-ratchet';
|
|
3
|
+
import { CliRatchet } from '../cli/cli-ratchet.js';
|
|
4
4
|
export class FilesToStaticClass {
|
|
5
5
|
static async process(fileNames, outClassName, outFileName = null) {
|
|
6
6
|
if (!fileNames) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { FilesToStaticClass } from './files-to-static-class.js';
|
|
3
|
+
import { EsmRatchet } from '@bitblit/ratchet-common/dist/lang/esm-ratchet.js';
|
|
4
|
+
const testDirname = EsmRatchet.fetchDirName();
|
|
5
|
+
describe('#filesToStaticClass', function () {
|
|
6
|
+
it('should convert files to a static class', async () => {
|
|
7
|
+
const out = await FilesToStaticClass.process([path.join(testDirname, 'files-to-static-class.ts'), path.join(testDirname, 'cli-ratchet.ts')], 'Test');
|
|
8
|
+
expect(out).not.toBeNull();
|
|
9
|
+
expect(out.length).toBeGreaterThan(0);
|
|
10
|
+
});
|
|
11
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import process from 'child_process';
|
|
2
|
-
import { Logger } from '@bitblit/ratchet-common';
|
|
2
|
+
import { Logger } from '@bitblit/ratchet-common/dist/logger/logger.js';
|
|
3
|
+
import { EsmRatchet } from '@bitblit/ratchet-common/dist/lang/esm-ratchet.js';
|
|
3
4
|
export class GitRatchet {
|
|
5
|
+
static SPLIT_CHARACTER = '<##>';
|
|
6
|
+
static PRETTY_FORMAT = ['%h', '%H', '%s', '%f', '%b', '%at', '%ct', '%an', '%ae', '%cn', '%ce', '%N', ''];
|
|
4
7
|
static async executeCommand(command, options) {
|
|
5
|
-
let dst =
|
|
8
|
+
let dst = EsmRatchet.fetchDirName();
|
|
6
9
|
if (!!options && !!options.dst) {
|
|
7
10
|
dst = options.dst;
|
|
8
11
|
}
|
|
@@ -65,5 +68,3 @@ export class GitRatchet {
|
|
|
65
68
|
return rval;
|
|
66
69
|
}
|
|
67
70
|
}
|
|
68
|
-
GitRatchet.SPLIT_CHARACTER = '<##>';
|
|
69
|
-
GitRatchet.PRETTY_FORMAT = ['%h', '%H', '%s', '%f', '%b', '%at', '%ct', '%an', '%ae', '%cn', '%ce', '%N', ''];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GitRatchet } from './git-ratchet.js';
|
|
2
|
+
import { Logger } from '@bitblit/ratchet-common/dist/logger/logger.js';
|
|
3
|
+
describe('#gitRatchet', function () {
|
|
4
|
+
it('should fetch last commit data', async () => {
|
|
5
|
+
const res = await GitRatchet.getLastCommitSwallowException();
|
|
6
|
+
expect(res).toBeTruthy();
|
|
7
|
+
Logger.info('Got: %j', res);
|
|
8
|
+
}, 10_000);
|
|
9
|
+
});
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
export declare class PublishCiReleaseToSlack {
|
|
2
2
|
static process(slackHookUrl: string, timezone?: string): Promise<string>;
|
|
3
3
|
static extractHookUrl(): string;
|
|
4
|
-
/**
|
|
5
|
-
And, in case you are running this command line...
|
|
6
|
-
TODO: should use switches to allow setting the various non-filename params
|
|
7
|
-
**/
|
|
8
4
|
static runFromCliArgs(args: string[]): Promise<string>;
|
|
9
5
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { DateTime } from 'luxon';
|
|
2
|
-
import {
|
|
2
|
+
import { Logger } from '@bitblit/ratchet-common/dist/logger/logger.js';
|
|
3
|
+
import { GlobalRatchet } from '@bitblit/ratchet-common/dist/lang/global-ratchet.js';
|
|
3
4
|
import fetch from 'cross-fetch';
|
|
4
5
|
import util from 'util';
|
|
5
|
-
import { GitRatchet } from '../git/git-ratchet';
|
|
6
|
+
import { GitRatchet } from '../git/git-ratchet.js';
|
|
6
7
|
export class PublishCiReleaseToSlack {
|
|
7
8
|
static async process(slackHookUrl, timezone = 'America/Los_Angeles') {
|
|
8
9
|
if (!slackHookUrl) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Logger } from '@bitblit/ratchet-common/dist/logger/logger.js';
|
|
2
|
+
import { GlobalRatchet } from '@bitblit/ratchet-common/dist/lang/global-ratchet.js';
|
|
3
|
+
import { PublishCiReleaseToSlack } from './publish-ci-release-to-slack.js';
|
|
4
|
+
describe('#publishCircleCiReleaseToSlack', function () {
|
|
5
|
+
xit('should fail if not in a circle ci environment', async () => {
|
|
6
|
+
try {
|
|
7
|
+
const result = await PublishCiReleaseToSlack.process('https://testslack.erigir.com');
|
|
8
|
+
this.bail();
|
|
9
|
+
}
|
|
10
|
+
catch (err) {
|
|
11
|
+
Logger.debug('Caught expected error : %s', err);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
xit('should not fail if in a circle ci environment', async () => {
|
|
15
|
+
GlobalRatchet.setGlobalVar('CIRCLE_BUILD_NUM', '1');
|
|
16
|
+
GlobalRatchet.setGlobalVar('CIRCLE_BRANCH', 'B');
|
|
17
|
+
GlobalRatchet.setGlobalVar('CIRCLE_TAG', 'T');
|
|
18
|
+
GlobalRatchet.setGlobalVar('CIRCLE_SHA1', 'S');
|
|
19
|
+
GlobalRatchet.setGlobalVar('CIRCLE_USERNAME', 'cweiss');
|
|
20
|
+
GlobalRatchet.setGlobalVar('CIRCLE_PROJECT_REPONAME', 'tester');
|
|
21
|
+
const result = await PublishCiReleaseToSlack.process('slackUrlHere');
|
|
22
|
+
expect(result).toEqual('ok');
|
|
23
|
+
});
|
|
24
|
+
});
|
package/package.json
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bitblit/ratchet-node-only",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.102-alpha",
|
|
4
4
|
"description": "Ratchet tools for use on node-only",
|
|
5
5
|
"note-on-side-effects": "Technically the entries in 'bin' below might be side effects, but they are called explicitly",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"bin": {
|
|
8
8
|
"ratchet-cli": "./includes/cli.js"
|
|
9
9
|
},
|
|
10
|
-
"
|
|
11
|
-
"module": "
|
|
12
|
-
"types": "./dist/types/index.d.ts",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"module": "index.js",
|
|
13
12
|
"files": [
|
|
14
13
|
"dist/*",
|
|
15
14
|
"includes/*"
|
|
@@ -36,15 +35,14 @@
|
|
|
36
35
|
"scripts": {
|
|
37
36
|
"watch": "tsc-watch",
|
|
38
37
|
"clean": "shx rm -Rf dist",
|
|
39
|
-
"test": "jest",
|
|
38
|
+
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest",
|
|
40
39
|
"docs": "typedoc",
|
|
41
40
|
"lint": "eslint src/**/*.ts",
|
|
42
41
|
"lint-fix": "eslint --fix src/**/*.ts",
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"build
|
|
46
|
-
"build
|
|
47
|
-
"build:types": "tsc -p tsconfig.types.json"
|
|
42
|
+
"__generate-barrels": "barrelsby -q --delete -d src -e .*\\.spec\\.ts",
|
|
43
|
+
"__build": "yarn run generate-barrels && tsc",
|
|
44
|
+
"build": "tsc",
|
|
45
|
+
"force-build": "tsc --build --force"
|
|
48
46
|
},
|
|
49
47
|
"repository": {
|
|
50
48
|
"type": "git",
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RatchetNodeOnlyInfo = void 0;
|
|
4
|
-
class RatchetNodeOnlyInfo {
|
|
5
|
-
constructor() { }
|
|
6
|
-
static buildInformation() {
|
|
7
|
-
const val = {
|
|
8
|
-
version: 'LOCAL-SNAPSHOT',
|
|
9
|
-
hash: 'LOCAL-HASH',
|
|
10
|
-
branch: 'LOCAL-BRANCH',
|
|
11
|
-
tag: 'LOCAL-TAG',
|
|
12
|
-
timeBuiltISO: 'LOCAL-TIME-ISO',
|
|
13
|
-
notes: 'LOCAL-NOTES',
|
|
14
|
-
};
|
|
15
|
-
return val;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.RatchetNodeOnlyInfo = RatchetNodeOnlyInfo;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ApplyCiEnvVariablesToFiles = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
|
-
const ratchet_common_1 = require("@bitblit/ratchet-common");
|
|
7
|
-
const ci_run_information_util_1 = require("./ci-run-information-util");
|
|
8
|
-
class ApplyCiEnvVariablesToFiles {
|
|
9
|
-
static async process(fileNames, cfg, buildFinder = 'LOCAL-SNAPSHOT', branchFinder = 'LOCAL-BRANCH', hashFinder = 'LOCAL-HASH', tagFinder = 'LOCAL-TAG', timeFinder = 'LOCAL-TIME') {
|
|
10
|
-
ratchet_common_1.RequireRatchet.notNullOrUndefined(cfg, 'cfg');
|
|
11
|
-
ratchet_common_1.RequireRatchet.notNullOrUndefined(cfg.buildNumber, 'cfg.buildNumber');
|
|
12
|
-
ratchet_common_1.RequireRatchet.notNullOrUndefined(cfg.localTime, 'cfg.localTime');
|
|
13
|
-
if (!fileNames) {
|
|
14
|
-
throw new Error('fileNames must be defined');
|
|
15
|
-
}
|
|
16
|
-
if (fileNames.length === 0) {
|
|
17
|
-
ratchet_common_1.Logger.warn('Warning - no files supplied to process');
|
|
18
|
-
}
|
|
19
|
-
if (!cfg.buildNumber) {
|
|
20
|
-
ratchet_common_1.ErrorRatchet.throwFormattedErr('%s env var not set - apparently not in a CI environment', cfg.buildNumber);
|
|
21
|
-
}
|
|
22
|
-
ratchet_common_1.Logger.info('Processing files %j with run info %j', cfg);
|
|
23
|
-
let foundCount = 0;
|
|
24
|
-
fileNames.forEach((f) => {
|
|
25
|
-
if (!fs_1.default.existsSync(f)) {
|
|
26
|
-
ratchet_common_1.Logger.error('Could not find file %s to process, continuing', f);
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
try {
|
|
30
|
-
let contents = fs_1.default.readFileSync(f).toString();
|
|
31
|
-
contents = contents.split(buildFinder).join(cfg.buildNumber);
|
|
32
|
-
contents = contents.split(branchFinder).join(cfg.branch || '');
|
|
33
|
-
contents = contents.split(hashFinder).join(cfg.commitHash || '');
|
|
34
|
-
contents = contents.split(tagFinder).join(cfg.tag || '');
|
|
35
|
-
contents = contents.split(timeFinder).join(cfg.localTime || '');
|
|
36
|
-
fs_1.default.writeFileSync(f, contents);
|
|
37
|
-
foundCount++;
|
|
38
|
-
}
|
|
39
|
-
catch (err) {
|
|
40
|
-
ratchet_common_1.Logger.error('Error processing %s , continuing: %s', f, err, err);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
return foundCount;
|
|
45
|
-
}
|
|
46
|
-
static extractFileNames() {
|
|
47
|
-
let rval = [];
|
|
48
|
-
if (process && process.argv && process.argv.length > 3) {
|
|
49
|
-
rval = process.argv.slice(3);
|
|
50
|
-
}
|
|
51
|
-
return rval;
|
|
52
|
-
}
|
|
53
|
-
static extractVariableConfig(inName) {
|
|
54
|
-
let rval = null;
|
|
55
|
-
const name = ratchet_common_1.StringRatchet.trimToEmpty(inName).toLowerCase();
|
|
56
|
-
switch (name) {
|
|
57
|
-
case 'circleci':
|
|
58
|
-
rval = ci_run_information_util_1.CiRunInformationUtil.createDefaultCircleCiRunInformation();
|
|
59
|
-
break;
|
|
60
|
-
case 'github':
|
|
61
|
-
rval = ci_run_information_util_1.CiRunInformationUtil.createDefaultGithubActionsRunInformation();
|
|
62
|
-
break;
|
|
63
|
-
case 'test':
|
|
64
|
-
rval = ci_run_information_util_1.CiRunInformationUtil.createTestingCiRunInformation();
|
|
65
|
-
break;
|
|
66
|
-
default:
|
|
67
|
-
ratchet_common_1.ErrorRatchet.throwFormattedErr('Unrecognized env var config type : %s', name);
|
|
68
|
-
}
|
|
69
|
-
ratchet_common_1.Logger.info('Using variable config : %j', rval);
|
|
70
|
-
return rval;
|
|
71
|
-
}
|
|
72
|
-
static async runFromCliArgs(args) {
|
|
73
|
-
if (args.length > 1) {
|
|
74
|
-
return ApplyCiEnvVariablesToFiles.process(args.slice(1), ApplyCiEnvVariablesToFiles.extractVariableConfig(args[0]));
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
ratchet_common_1.Logger.infoP('Usage : apply-ci-env-variables-to-files {file1} {file2} ...');
|
|
78
|
-
return -1;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
exports.ApplyCiEnvVariablesToFiles = ApplyCiEnvVariablesToFiles;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CiRunInformationUtil = void 0;
|
|
4
|
-
const luxon_1 = require("luxon");
|
|
5
|
-
const ratchet_common_1 = require("@bitblit/ratchet-common");
|
|
6
|
-
class CiRunInformationUtil {
|
|
7
|
-
static createTestingCiRunInformation(timezone = CiRunInformationUtil.DEFAULT_TIME_ZONE) {
|
|
8
|
-
const now = new Date().toISOString();
|
|
9
|
-
const rval = {
|
|
10
|
-
buildNumber: 'Test_buildNumberVar_' + now,
|
|
11
|
-
localTime: luxon_1.DateTime.local().setZone(timezone).toFormat(CiRunInformationUtil.DEFAULT_TIME_FORMAT),
|
|
12
|
-
branch: 'Test_branchVar_' + now,
|
|
13
|
-
tag: 'Test_tagVar_' + now,
|
|
14
|
-
commitHash: 'Test_hashVar_' + now,
|
|
15
|
-
userName: 'Test_userNameVar_' + now,
|
|
16
|
-
projectName: 'Test_projectNameVar_' + now,
|
|
17
|
-
};
|
|
18
|
-
return rval;
|
|
19
|
-
}
|
|
20
|
-
static createDefaultCircleCiRunInformation(timezone = CiRunInformationUtil.DEFAULT_TIME_ZONE) {
|
|
21
|
-
const rval = {
|
|
22
|
-
buildNumber: ratchet_common_1.GlobalRatchet.fetchGlobalVar('CIRCLE_BUILD_NUM'),
|
|
23
|
-
branch: ratchet_common_1.GlobalRatchet.fetchGlobalVar('CIRCLE_BRANCH'),
|
|
24
|
-
tag: ratchet_common_1.GlobalRatchet.fetchGlobalVar('CIRCLE_TAG'),
|
|
25
|
-
commitHash: ratchet_common_1.GlobalRatchet.fetchGlobalVar('CIRCLE_SHA1'),
|
|
26
|
-
localTime: luxon_1.DateTime.local().setZone(timezone).toFormat(CiRunInformationUtil.DEFAULT_TIME_FORMAT),
|
|
27
|
-
userName: ratchet_common_1.GlobalRatchet.fetchGlobalVar('CIRCLE_USERNAME'),
|
|
28
|
-
projectName: ratchet_common_1.GlobalRatchet.fetchGlobalVar('CIRCLE_PROJECT_REPONAME'),
|
|
29
|
-
};
|
|
30
|
-
return rval;
|
|
31
|
-
}
|
|
32
|
-
static createDefaultGithubActionsRunInformation(timezone = CiRunInformationUtil.DEFAULT_TIME_ZONE) {
|
|
33
|
-
const rval = {
|
|
34
|
-
buildNumber: ratchet_common_1.GlobalRatchet.fetchGlobalVar('GITHUB_RUN_NUMBER'),
|
|
35
|
-
branch: ratchet_common_1.GlobalRatchet.fetchGlobalVar('GITHUB_REF_NAME'),
|
|
36
|
-
tag: ratchet_common_1.GlobalRatchet.fetchGlobalVar('GITHUB_REF_NAME'),
|
|
37
|
-
commitHash: ratchet_common_1.GlobalRatchet.fetchGlobalVar('GITHUB_SHA'),
|
|
38
|
-
localTime: luxon_1.DateTime.local().setZone(timezone).toFormat(CiRunInformationUtil.DEFAULT_TIME_FORMAT),
|
|
39
|
-
userName: ratchet_common_1.GlobalRatchet.fetchGlobalVar('GITHUB_ACTOR'),
|
|
40
|
-
projectName: ratchet_common_1.GlobalRatchet.fetchGlobalVar('GITHUB_REPOSITORY'),
|
|
41
|
-
};
|
|
42
|
-
return rval;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
exports.CiRunInformationUtil = CiRunInformationUtil;
|
|
46
|
-
CiRunInformationUtil.DEFAULT_TIME_FORMAT = 'yyyy-MM-dd HH:mm:ss a z';
|
|
47
|
-
CiRunInformationUtil.DEFAULT_TIME_ZONE = 'America/Los_Angeles';
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AbstractRatchetCliHandler = void 0;
|
|
4
|
-
const cli_ratchet_1 = require("./cli-ratchet");
|
|
5
|
-
class AbstractRatchetCliHandler {
|
|
6
|
-
async findAndExecuteHandler() {
|
|
7
|
-
let handler = null;
|
|
8
|
-
if (cli_ratchet_1.CliRatchet.argsAfterCommand(['version'])) {
|
|
9
|
-
console.log('Version : ' + JSON.stringify(this.fetchVersionInfo()));
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
const handlerMap = this.fetchHandlerMap();
|
|
13
|
-
const keys = Object.keys(handlerMap);
|
|
14
|
-
let remainArgs = null;
|
|
15
|
-
for (let i = 0; i < keys.length && !handler; i++) {
|
|
16
|
-
remainArgs = cli_ratchet_1.CliRatchet.argsAfterCommand([keys[i], keys[i] + '.js']);
|
|
17
|
-
if (remainArgs) {
|
|
18
|
-
handler = handlerMap[keys[i]];
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
if (handler) {
|
|
22
|
-
console.debug('Running command with args ' + JSON.stringify(remainArgs));
|
|
23
|
-
await handler(remainArgs);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
console.log('Unrecognized command : ', process.argv);
|
|
27
|
-
console.log('Valid commands are : ', Object.keys(handlerMap));
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
exports.AbstractRatchetCliHandler = AbstractRatchetCliHandler;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CliRatchet = void 0;
|
|
4
|
-
class CliRatchet {
|
|
5
|
-
static isCalledFromCLI(filenames) {
|
|
6
|
-
let rval = false;
|
|
7
|
-
for (let i = 0; filenames && i < filenames.length && !rval; i++) {
|
|
8
|
-
rval = CliRatchet.indexOfCommandArgument(filenames[i]) > -1;
|
|
9
|
-
}
|
|
10
|
-
return rval;
|
|
11
|
-
}
|
|
12
|
-
static argsAfterCommand(filenames) {
|
|
13
|
-
var _a;
|
|
14
|
-
let rval = null;
|
|
15
|
-
if (((_a = process === null || process === void 0 ? void 0 : process.argv) === null || _a === void 0 ? void 0 : _a.length) && (filenames === null || filenames === void 0 ? void 0 : filenames.length)) {
|
|
16
|
-
let idx = null;
|
|
17
|
-
for (let i = 0; i < filenames.length && idx === null; i++) {
|
|
18
|
-
idx = CliRatchet.indexOfCommandArgument(filenames[i]);
|
|
19
|
-
}
|
|
20
|
-
rval = idx !== null ? process.argv.slice(idx + 1, process.argv.length) : null;
|
|
21
|
-
}
|
|
22
|
-
return rval;
|
|
23
|
-
}
|
|
24
|
-
static isCalledFromCLISingle(filename) {
|
|
25
|
-
return CliRatchet.isCalledFromCLI([filename]);
|
|
26
|
-
}
|
|
27
|
-
static indexOfCommandArgument(filename) {
|
|
28
|
-
const contFileName = process.argv.map((arg) => arg.indexOf(filename) !== -1);
|
|
29
|
-
const idx = contFileName.indexOf(true);
|
|
30
|
-
return idx === -1 ? null : idx;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.CliRatchet = CliRatchet;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RatchetCliHandler = void 0;
|
|
4
|
-
const ratchet_node_only_info_1 = require("../build/ratchet-node-only-info");
|
|
5
|
-
const apply_ci_env_variables_to_files_1 = require("../ci/apply-ci-env-variables-to-files");
|
|
6
|
-
const files_to_static_class_1 = require("../files/files-to-static-class");
|
|
7
|
-
const publish_ci_release_to_slack_1 = require("../third-party/slack/publish-ci-release-to-slack");
|
|
8
|
-
const abstract_ratchet_cli_handler_1 = require("./abstract-ratchet-cli-handler");
|
|
9
|
-
class RatchetCliHandler extends abstract_ratchet_cli_handler_1.AbstractRatchetCliHandler {
|
|
10
|
-
fetchHandlerMap() {
|
|
11
|
-
return {
|
|
12
|
-
'apply-ci-env-variables-to-files': apply_ci_env_variables_to_files_1.ApplyCiEnvVariablesToFiles.runFromCliArgs,
|
|
13
|
-
'files-to-static-class': files_to_static_class_1.FilesToStaticClass.runFromCliArgs,
|
|
14
|
-
'publish-ci-release-to-slack': publish_ci_release_to_slack_1.PublishCiReleaseToSlack.runFromCliArgs,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
fetchVersionInfo() {
|
|
18
|
-
return ratchet_node_only_info_1.RatchetNodeOnlyInfo.buildInformation();
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.RatchetCliHandler = RatchetCliHandler;
|