Compare commits
No commits in common. "master" and "dev" have entirely different histories.
14
.drone.yml
14
.drone.yml
@ -1,14 +0,0 @@
|
|||||||
kind: pipeline
|
|
||||||
name: default
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: setup
|
|
||||||
image: registry:5000/node-build
|
|
||||||
commands:
|
|
||||||
- yarn
|
|
||||||
- curl https://git.scode.ovh/Timo/standard/raw/branch/master/ci.js > ci.js
|
|
||||||
|
|
||||||
- name: build
|
|
||||||
image: registry:5000/node-build
|
|
||||||
commands:
|
|
||||||
- node ci.js
|
|
12
CHANGELOG.md
12
CHANGELOG.md
@ -1,15 +1,5 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## 1.5.0
|
|
||||||
|
|
||||||
Node template: use jasmine instead of ava
|
|
||||||
|
|
||||||
## 1.4.0
|
|
||||||
|
|
||||||
Drone template
|
|
||||||
|
|
||||||
Jenkins template: remove node specific template (replaced by drone)
|
|
||||||
|
|
||||||
## 1.3.0
|
## 1.3.0
|
||||||
|
|
||||||
Copyright function: carry previous creation date to prevent unnecessary modifications
|
Copyright function: carry previous creation date to prevent unnecessary modifications
|
||||||
@ -17,7 +7,7 @@ Copyright function: carry previous creation date to prevent unnecessary modifica
|
|||||||
## 1.2.0
|
## 1.2.0
|
||||||
|
|
||||||
- Fully interactive snippets
|
- Fully interactive snippets
|
||||||
- db migration generator removed
|
- db migration generator removed (new snipped in development)
|
||||||
|
|
||||||
## 1.1.0
|
## 1.1.0
|
||||||
|
|
||||||
|
23
Jenkinsfile
vendored
Normal file
23
Jenkinsfile
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
|
||||||
|
environment {
|
||||||
|
VERSION = VersionNumber([
|
||||||
|
versionNumberString:
|
||||||
|
'${BUILDS_ALL_TIME}',
|
||||||
|
versionPrefix: '1.3.',
|
||||||
|
worstResultForIncrement: 'SUCCESS'
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
stages {
|
||||||
|
stage('Building') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
currentBuild.displayName = env.VERSION
|
||||||
|
}
|
||||||
|
sh 'yarn ci ${VERSION}'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
# @sapphirecode/snippeteer
|
# @sapphirecode/snippeteer
|
||||||
|
|
||||||
version: 1.5.x
|
version: 1.3.x
|
||||||
|
|
||||||
macros for setting up projects or project parts
|
macros for setting up projects or project parts
|
||||||
|
|
||||||
@ -31,9 +31,8 @@ license file and adding fields like author and license to the package.json
|
|||||||
|
|
||||||
create a generic jenkinsfile
|
create a generic jenkinsfile
|
||||||
|
|
||||||
#### drone
|
for node projects: automatically generates a jenkinsfile and jenkins.js for easy
|
||||||
|
use in jenkins.
|
||||||
create a generic .drone.yml for deployment of node projects
|
|
||||||
|
|
||||||
necessary scripts in the package.json:
|
necessary scripts in the package.json:
|
||||||
|
|
||||||
|
29
jenkins.js
Normal file
29
jenkins.js
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) SapphireCode - All Rights Reserved
|
||||||
|
* This file is part of Snippeteer which is released under BSD-3-Clause.
|
||||||
|
* See file 'LICENSE' for full license details.
|
||||||
|
* Created by Timo Hocker <timo@scode.ovh>, June 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);
|
||||||
|
}
|
||||||
|
);
|
@ -13,7 +13,7 @@ export class FileMapper {
|
|||||||
public static async map_all_files (
|
public static async map_all_files (
|
||||||
folder: string,
|
folder: string,
|
||||||
mutator: (data: string, file: string, args: Array<unknown>) => string|null,
|
mutator: (data: string, file: string, args: Array<unknown>) => string|null,
|
||||||
opts: Array<unknown> = []
|
args: Array<unknown> = []
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const files = await fs.readdir (folder);
|
const files = await fs.readdir (folder);
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
@ -21,11 +21,11 @@ export class FileMapper {
|
|||||||
continue;
|
continue;
|
||||||
const abs_path = path.join (folder, file);
|
const abs_path = path.join (folder, file);
|
||||||
if ((await fs.stat (abs_path)).isDirectory ()) {
|
if ((await fs.stat (abs_path)).isDirectory ()) {
|
||||||
await FileMapper.map_all_files (abs_path, mutator, opts);
|
await FileMapper.map_all_files (abs_path, mutator, args);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const data = await fs.readFile (abs_path, 'utf-8');
|
const data = await fs.readFile (abs_path, 'utf-8');
|
||||||
const res = mutator (data, file, opts);
|
const res = mutator (data, file, args);
|
||||||
if (res === null)
|
if (res === null)
|
||||||
continue;
|
continue;
|
||||||
await fs.writeFile (abs_path, res, 'utf-8');
|
await fs.writeFile (abs_path, res, 'utf-8');
|
||||||
|
@ -41,7 +41,7 @@ export default class Copyright implements Snippet {
|
|||||||
);
|
);
|
||||||
|
|
||||||
await modify_json ((json) => {
|
await modify_json ((json) => {
|
||||||
json.author = { name: options.author, email: options.email };
|
json.author = `${options.author} <${options.email}>`;
|
||||||
json.license = options.has_license ? options.license : 'UNLICENSED';
|
json.license = options.has_license ? options.license : 'UNLICENSED';
|
||||||
return json;
|
return json;
|
||||||
});
|
});
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) SapphireCode - All Rights Reserved
|
|
||||||
* This file is part of Snippeteer which is released under BSD-3-Clause.
|
|
||||||
* See file 'LICENSE' for full license details.
|
|
||||||
* Created by Timo Hocker <timo@scode.ovh>, July 2020
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { files } from '@sapphirecode/standard';
|
|
||||||
import { Snippet } from '../../Snippet';
|
|
||||||
import { apply_template } from '../../Helper';
|
|
||||||
|
|
||||||
export default class Drone implements Snippet {
|
|
||||||
public is_active (): boolean {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async start (): Promise<void> {
|
|
||||||
await apply_template (files.drone, '.drone.yml');
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,7 +7,10 @@
|
|||||||
|
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
|
|
||||||
|
import { files } from '@sapphirecode/standard';
|
||||||
|
|
||||||
const general = { jenkinsfile: '' };
|
const general = { jenkinsfile: '' };
|
||||||
|
const node = { jenkinsfile: files.jenkinsfile, js: files.jenkins };
|
||||||
|
|
||||||
general.jenkinsfile = `pipeline {
|
general.jenkinsfile = `pipeline {
|
||||||
agent any
|
agent any
|
||||||
@ -50,4 +53,4 @@ general.jenkinsfile = `pipeline {
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export { general };
|
export { general, node };
|
||||||
|
@ -5,10 +5,11 @@
|
|||||||
* Created by Timo Hocker <timo@scode.ovh>, May 2020
|
* Created by Timo Hocker <timo@scode.ovh>, May 2020
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { Confirm } from 'enquirer';
|
||||||
import { Snippet } from '../../Snippet';
|
import { Snippet } from '../../Snippet';
|
||||||
import { apply_template } from '../../Helper';
|
import { apply_template, modify_json } from '../../Helper';
|
||||||
|
|
||||||
import { general } from './Assets';
|
import { general, node } from './Assets';
|
||||||
|
|
||||||
export default class Jenkins implements Snippet {
|
export default class Jenkins implements Snippet {
|
||||||
public is_active (): boolean {
|
public is_active (): boolean {
|
||||||
@ -16,6 +17,23 @@ export default class Jenkins implements Snippet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async start (): Promise<void> {
|
public async start (): Promise<void> {
|
||||||
|
const is_node = await new Confirm ({
|
||||||
|
message: 'is the current project using nodejs?',
|
||||||
|
initial: true
|
||||||
|
})
|
||||||
|
.run ();
|
||||||
|
|
||||||
|
if (is_node) {
|
||||||
|
await apply_template (node.js, 'jenkins.js');
|
||||||
|
await apply_template (node.jenkinsfile, 'Jenkinsfile');
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
await modify_json ((obj: any): any => {
|
||||||
|
obj.scripts.ci = 'yarn && node jenkins.js';
|
||||||
|
return obj;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
await apply_template (general.jenkinsfile, 'Jenkinsfile');
|
await apply_template (general.jenkinsfile, 'Jenkinsfile');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,7 @@
|
|||||||
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { Input, Confirm } from 'enquirer';
|
import { Input, Confirm } from 'enquirer';
|
||||||
import {
|
import { scripts as standard_scripts } from '@sapphirecode/standard';
|
||||||
scripts as standard_scripts,
|
|
||||||
files as standard_files
|
|
||||||
} from '@sapphirecode/standard';
|
|
||||||
import fs from 'fs-extra';
|
|
||||||
import { Snippet } from '../../Snippet';
|
import { Snippet } from '../../Snippet';
|
||||||
import { apply_template, modify_json, run_command } from '../../Helper';
|
import { apply_template, modify_json, run_command } from '../../Helper';
|
||||||
|
|
||||||
@ -20,22 +16,6 @@ import {
|
|||||||
tsconfig, eslintrc_ts, eslintignore
|
tsconfig, eslintrc_ts, eslintignore
|
||||||
} from './Assets';
|
} from './Assets';
|
||||||
|
|
||||||
|
|
||||||
const packages = {
|
|
||||||
common: [ 'eslint' ],
|
|
||||||
js: [ '@sapphirecode/eslint-config' ],
|
|
||||||
ts: [
|
|
||||||
'typescript',
|
|
||||||
'@sapphirecode/eslint-config-ts'
|
|
||||||
],
|
|
||||||
test: [
|
|
||||||
'nyc',
|
|
||||||
'jasmine',
|
|
||||||
'@types/jasmine'
|
|
||||||
],
|
|
||||||
test_ts: [ 'ts-node' ]
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* initialize the package.json
|
* initialize the package.json
|
||||||
*
|
*
|
||||||
@ -48,22 +28,8 @@ async function init_package (
|
|||||||
use_ts: boolean,
|
use_ts: boolean,
|
||||||
use_tests: boolean
|
use_tests: boolean
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
run_command ('yarn init -y', folder);
|
|
||||||
|
|
||||||
const bundle = [
|
|
||||||
...packages.common,
|
|
||||||
...(use_ts ? packages.ts : packages.js),
|
|
||||||
...(use_tests ? packages.test : []),
|
|
||||||
...(use_ts && use_tests ? packages.test_ts : [])
|
|
||||||
];
|
|
||||||
|
|
||||||
run_command (
|
|
||||||
`yarn add --dev ${bundle.join (' ')}`,
|
|
||||||
folder
|
|
||||||
);
|
|
||||||
|
|
||||||
await modify_json ((obj: Record<string, unknown>) => {
|
await modify_json ((obj: Record<string, unknown>) => {
|
||||||
const scripts: Record<string, string>
|
const scripts
|
||||||
= {
|
= {
|
||||||
lint: standard_scripts.lint,
|
lint: standard_scripts.lint,
|
||||||
test: standard_scripts.test.common,
|
test: standard_scripts.test.common,
|
||||||
@ -73,9 +39,7 @@ async function init_package (
|
|||||||
|
|
||||||
if (use_ts) {
|
if (use_ts) {
|
||||||
scripts.compile = standard_scripts.compile.ts;
|
scripts.compile = standard_scripts.compile.ts;
|
||||||
scripts.pretest = standard_scripts.test.ts_pre;
|
|
||||||
scripts.test = standard_scripts.test.ts;
|
scripts.test = standard_scripts.test.ts;
|
||||||
scripts.posttest = standard_scripts.test.ts_post;
|
|
||||||
files.push ('/dist/');
|
files.push ('/dist/');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -128,14 +92,13 @@ export default class Node implements Snippet {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
run_command ('git init', folder);
|
run_command ('git init', folder);
|
||||||
|
run_command ('yarn init -y', folder);
|
||||||
if (use_tests) {
|
run_command (
|
||||||
await apply_template (
|
`yarn add --dev @sapphirecode/eslint-config${use_ts
|
||||||
standard_files.jasmine,
|
? '-ts typescript @ava/typescript'
|
||||||
path.join (folder, 'jasmine.json')
|
: ''} eslint nyc ava`,
|
||||||
|
folder
|
||||||
);
|
);
|
||||||
await fs.mkdirp (path.join (folder, 'test/spec'));
|
|
||||||
}
|
|
||||||
|
|
||||||
await init_package (folder, use_ts, use_tests);
|
await init_package (folder, use_ts, use_tests);
|
||||||
}
|
}
|
||||||
|
@ -31,9 +31,6 @@ export default class Readme implements Snippet {
|
|||||||
package_data.software = json.name;
|
package_data.software = json.name;
|
||||||
package_data.description = json.description;
|
package_data.description = json.description;
|
||||||
package_data.license = json.license;
|
package_data.license = json.license;
|
||||||
if (typeof json.author === 'object')
|
|
||||||
package_data.author = `${json.author.name} <${json.author.email}>`;
|
|
||||||
else
|
|
||||||
package_data.author = json.author;
|
package_data.author = json.author;
|
||||||
});
|
});
|
||||||
const readme = get_readme (
|
const readme = get_readme (
|
||||||
|
29
package.json
29
package.json
@ -1,49 +1,44 @@
|
|||||||
{
|
{
|
||||||
"name": "@sapphirecode/snippeteer",
|
"name": "@sapphirecode/snippeteer",
|
||||||
"version": "1.5.6",
|
"version": "1.0.0",
|
||||||
"description": "macros for setting up projects or project parts",
|
"description": "macros for setting up projects or project parts",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
"snippeteer": "./index.js"
|
"snippeteer": "./index.js"
|
||||||
},
|
},
|
||||||
"bugs": "https://redmine.scode.ovh/projects/snippeteer",
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "eslint . --ext .js,.jsx,.ts,.tsx,.vue,.mjs",
|
"lint": "eslint . --ext .js,.jsx,.ts,.tsx,.vue,.mjs",
|
||||||
|
"ci": "yarn --frozen-lockfile && node jenkins.js",
|
||||||
"test": "echo \"no test\"",
|
"test": "echo \"no test\"",
|
||||||
"compile": "tsc"
|
"compile": "tsc"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git.scode.ovh:timo/snippeteer.git"
|
"url": "git@git.scode.ovh:timo/snippeteer"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"/dist/",
|
"/dist/",
|
||||||
"/lib/",
|
"/lib/",
|
||||||
"LICENSE"
|
"LICENSE"
|
||||||
],
|
],
|
||||||
"author": {
|
"author": "Timo Hocker <timo@scode.ovh>",
|
||||||
"name": "Timo Hocker",
|
|
||||||
"email": "timo@scode.ovh"
|
|
||||||
},
|
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@sapphirecode/eslint-config-ts": "^1.0.22",
|
"@sapphirecode/eslint-config-ts": "^1.0.22",
|
||||||
"@types/fs-extra": "^9.0.0",
|
"@types/fs-extra": "^9.0.0",
|
||||||
"@types/node": "^17.0.2",
|
"@types/node": "^14.0.1",
|
||||||
"eslint": "^8.5.0",
|
"eslint": "^7.0.0",
|
||||||
"typescript": "^4.0.2"
|
"typescript": "^3.8.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sapphirecode/standard": "^1.5.5",
|
"@sapphirecode/console-app": "^2.0.6",
|
||||||
|
"@sapphirecode/modelling": "^1.1.6",
|
||||||
|
"@sapphirecode/standard": "^1.0.1",
|
||||||
"enquirer": "^2.3.5",
|
"enquirer": "^2.3.5",
|
||||||
"fs-extra": "^10.0.0",
|
"fs-extra": "^9.0.0",
|
||||||
"license": "^1.0.3"
|
"license": "^1.0.3"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.0.0"
|
"node": ">=10.0.0"
|
||||||
},
|
}
|
||||||
"keywords": [
|
|
||||||
"snippet",
|
|
||||||
"template"
|
|
||||||
]
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user