Compare commits

...

4 Commits
master ... dev

Author SHA1 Message Date
4fdfe1314e switch to drone
Some checks failed
continuous-integration/drone/push Build is failing
2020-07-10 08:31:51 +02:00
4397e5f2c4 Merge branch 'master' into dev 2020-06-22 08:29:13 +02:00
62ae2990a6 prompt will have to be self made, or extending more basic levels of enquirer 2020-06-18 13:58:38 +02:00
f372e1ea17 path selector 2020-06-16 12:52:41 +02:00
9 changed files with 94 additions and 65 deletions

20
.drone.yml Normal file
View 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

View File

@ -20,18 +20,20 @@ const {
} = require ('./dist/lib/index.js');
(async () => {
const str = await new StringOption ({ name: 'str' })
.parse ();
const bool = await new BooleanOption ({ name: 'bool' })
.parse ();
const num = await new NumberOption ({ name: 'num' })
.parse ();
const arr = await new ArrayOption ({ name: 'arr' })
.parse ();
/*
* const str = await new StringOption ({ name: 'str' })
*.parse ();
*const bool = await new BooleanOption ({ name: 'bool' })
*.parse ();
*const num = await new NumberOption ({ name: 'num' })
*.parse ();
*const arr = await new ArrayOption ({ name: 'arr' })
*.parse ();
*/
const fld = await new FolderOption ({ name: 'fld' })
.parse ();
const data = { str, bool, num, arr, fld };
const data = { /* str, bool, num, arr,*/ fld };
console.log (data);
}) ();

23
Jenkinsfile vendored
View File

@ -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}'
}
}
}
}

View File

@ -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);
}
);

View 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;
}
}

View 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 ()
);
}
}

View File

@ -2,10 +2,12 @@ import { ArraySubSource } from './ArraySubSource';
import { BooleanSubSource } from './BooleanSubSource';
import { PresetSubSource } from './PresetSubSource';
import { StringSubSource } from './StringSubSource';
import { PathSubSource } from './PathSubSource';
export const sources = [
ArraySubSource,
BooleanSubSource,
PresetSubSource,
PathSubSource,
StringSubSource
];

View File

@ -1,6 +1,6 @@
{
"name": "@sapphirecode/console-app",
"version": "1.0.0",
"version": "2.0.7",
"main": "dist/lib/index.js",
"author": "Timo Hocker <timo@scode.ovh>",
"license": "MIT",
@ -23,8 +23,7 @@
"scripts": {
"lint": "eslint . --ext .js,.jsx,.ts,.tsx,.vue,.mjs",
"test": "tsc && nyc ava",
"compile": "tsc",
"ci": "yarn && node jenkins.js"
"compile": "tsc"
},
"files": [
"LICENSE",

View File

@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es5",
"target": "es6",
"module": "commonjs",
"outDir": "./dist",
"rootDir": "./",