Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
4fdfe1314e | |||
4397e5f2c4 | |||
62ae2990a6 | |||
f372e1ea17 |
20
.drone.yml
Normal file
20
.drone.yml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
kind: pipeline
|
||||||
|
name: default
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: setup
|
||||||
|
image: node:lts-alpine
|
||||||
|
commands:
|
||||||
|
- apk add --no-cache curl
|
||||||
|
- yarn
|
||||||
|
- curl https://git.scode.ovh/Timo/standard/raw/branch/master/ci.js > ci.js
|
||||||
|
|
||||||
|
- name: build
|
||||||
|
image: node:lts-alpine
|
||||||
|
environment:
|
||||||
|
TOKEN:
|
||||||
|
from_secret: npm_token
|
||||||
|
commands:
|
||||||
|
- echo "$TOKEN" > ~/.npmrc
|
||||||
|
- npm i -g typescript
|
||||||
|
- node ci.js
|
20
AppTest.js
20
AppTest.js
@ -20,18 +20,20 @@ const {
|
|||||||
} = require ('./dist/lib/index.js');
|
} = require ('./dist/lib/index.js');
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const str = await new StringOption ({ name: 'str' })
|
/*
|
||||||
.parse ();
|
* const str = await new StringOption ({ name: 'str' })
|
||||||
const bool = await new BooleanOption ({ name: 'bool' })
|
*.parse ();
|
||||||
.parse ();
|
*const bool = await new BooleanOption ({ name: 'bool' })
|
||||||
const num = await new NumberOption ({ name: 'num' })
|
*.parse ();
|
||||||
.parse ();
|
*const num = await new NumberOption ({ name: 'num' })
|
||||||
const arr = await new ArrayOption ({ name: 'arr' })
|
*.parse ();
|
||||||
.parse ();
|
*const arr = await new ArrayOption ({ name: 'arr' })
|
||||||
|
*.parse ();
|
||||||
|
*/
|
||||||
const fld = await new FolderOption ({ name: 'fld' })
|
const fld = await new FolderOption ({ name: 'fld' })
|
||||||
.parse ();
|
.parse ();
|
||||||
|
|
||||||
const data = { str, bool, num, arr, fld };
|
const data = { /* str, bool, num, arr,*/ fld };
|
||||||
|
|
||||||
console.log (data);
|
console.log (data);
|
||||||
}) ();
|
}) ();
|
||||||
|
23
Jenkinsfile
vendored
23
Jenkinsfile
vendored
@ -1,23 +0,0 @@
|
|||||||
pipeline {
|
|
||||||
agent any
|
|
||||||
|
|
||||||
environment {
|
|
||||||
VERSION = VersionNumber([
|
|
||||||
versionNumberString:
|
|
||||||
'${BUILDS_ALL_TIME}',
|
|
||||||
versionPrefix: '2.0.',
|
|
||||||
worstResultForIncrement: 'SUCCESS'
|
|
||||||
])
|
|
||||||
}
|
|
||||||
|
|
||||||
stages {
|
|
||||||
stage('Building') {
|
|
||||||
steps {
|
|
||||||
script {
|
|
||||||
currentBuild.displayName = env.VERSION
|
|
||||||
}
|
|
||||||
sh 'yarn ci ${VERSION}'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
29
jenkins.js
29
jenkins.js
@ -1,29 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) Sapphirecode - All Rights Reserved
|
|
||||||
* This file is part of console-app which is released under MIT.
|
|
||||||
* See file 'LICENSE' for full license details.
|
|
||||||
* Created by Timo Hocker <timo@scode.ovh>, May 2020
|
|
||||||
*/
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const https = require ('https');
|
|
||||||
const fs = require ('fs');
|
|
||||||
const { execSync: exec_sync } = require ('child_process');
|
|
||||||
|
|
||||||
const run_file = fs.createWriteStream ('.jenkins.run.js');
|
|
||||||
|
|
||||||
const [
|
|
||||||
,, ...args
|
|
||||||
] = process.argv;
|
|
||||||
|
|
||||||
run_file.on ('close', () => {
|
|
||||||
exec_sync (`node .jenkins.run.js ${args.join (' ')}`, { stdio: 'inherit' });
|
|
||||||
});
|
|
||||||
|
|
||||||
https.get (
|
|
||||||
'https://git.scode.ovh/Timo/standard/raw/branch/master/jenkins.run.js',
|
|
||||||
(msg) => {
|
|
||||||
msg.pipe (run_file);
|
|
||||||
}
|
|
||||||
);
|
|
34
lib/Sources/Interactive/PathCustomPrompt.ts
Normal file
34
lib/Sources/Interactive/PathCustomPrompt.ts
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/* eslint-disable no-sync */
|
||||||
|
import { dirname, join, sep, basename } from 'path';
|
||||||
|
import fs from 'fs-extra';
|
||||||
|
|
||||||
|
function read_dir (dir:string, exclude_files:boolean):string[] {
|
||||||
|
const contents = fs.readdirSync (dir);
|
||||||
|
contents.unshift ('..');
|
||||||
|
if (exclude_files) {
|
||||||
|
return contents.filter ((c) => {
|
||||||
|
const full_path = join (dir, c);
|
||||||
|
try {
|
||||||
|
return fs.statSync (full_path)
|
||||||
|
.isDirectory ();
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return contents;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface PathPromptOptions {
|
||||||
|
starting_dir?: string;
|
||||||
|
folders_only?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class PathPrompt {
|
||||||
|
private _options: PathPromptOptions;
|
||||||
|
|
||||||
|
public constructor (options:PathPromptOptions) {
|
||||||
|
this._options = options;
|
||||||
|
}
|
||||||
|
}
|
24
lib/Sources/Interactive/PathSubSource.ts
Normal file
24
lib/Sources/Interactive/PathSubSource.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import { InteractiveSubSource } from './InteractiveSubSource';
|
||||||
|
import { PathPrompt } from './PathCustomPrompt';
|
||||||
|
|
||||||
|
export class PathSubSource extends InteractiveSubSource {
|
||||||
|
protected condition ():boolean {
|
||||||
|
return [
|
||||||
|
'path',
|
||||||
|
'file',
|
||||||
|
'folder'
|
||||||
|
].includes (this.val.type_validation.option_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async run (): Promise<void> {
|
||||||
|
await this.val.assign_arg (
|
||||||
|
this.opt,
|
||||||
|
await new PathPrompt ({
|
||||||
|
message: this.get_message (),
|
||||||
|
default: this.opt.default,
|
||||||
|
folder_only: this.val.type_validation.option_type === 'folder'
|
||||||
|
})
|
||||||
|
.run ()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -2,10 +2,12 @@ import { ArraySubSource } from './ArraySubSource';
|
|||||||
import { BooleanSubSource } from './BooleanSubSource';
|
import { BooleanSubSource } from './BooleanSubSource';
|
||||||
import { PresetSubSource } from './PresetSubSource';
|
import { PresetSubSource } from './PresetSubSource';
|
||||||
import { StringSubSource } from './StringSubSource';
|
import { StringSubSource } from './StringSubSource';
|
||||||
|
import { PathSubSource } from './PathSubSource';
|
||||||
|
|
||||||
export const sources = [
|
export const sources = [
|
||||||
ArraySubSource,
|
ArraySubSource,
|
||||||
BooleanSubSource,
|
BooleanSubSource,
|
||||||
PresetSubSource,
|
PresetSubSource,
|
||||||
|
PathSubSource,
|
||||||
StringSubSource
|
StringSubSource
|
||||||
];
|
];
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@sapphirecode/console-app",
|
"name": "@sapphirecode/console-app",
|
||||||
"version": "1.0.0",
|
"version": "2.0.7",
|
||||||
"main": "dist/lib/index.js",
|
"main": "dist/lib/index.js",
|
||||||
"author": "Timo Hocker <timo@scode.ovh>",
|
"author": "Timo Hocker <timo@scode.ovh>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@ -23,8 +23,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "eslint . --ext .js,.jsx,.ts,.tsx,.vue,.mjs",
|
"lint": "eslint . --ext .js,.jsx,.ts,.tsx,.vue,.mjs",
|
||||||
"test": "tsc && nyc ava",
|
"test": "tsc && nyc ava",
|
||||||
"compile": "tsc",
|
"compile": "tsc"
|
||||||
"ci": "yarn && node jenkins.js"
|
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"LICENSE",
|
"LICENSE",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es5",
|
"target": "es6",
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"outDir": "./dist",
|
"outDir": "./dist",
|
||||||
"rootDir": "./",
|
"rootDir": "./",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user