Compare commits
No commits in common. "214b113865311a7234a7930c688cda1404ff7018" and "6ff99c827d65c5b8c7c522435e9473081a9e91f0" have entirely different histories.
214b113865
...
6ff99c827d
21
.vscode/launch.json
vendored
21
.vscode/launch.json
vendored
@ -1,21 +0,0 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Launch Program",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"program": "${workspaceFolder}\\index.js",
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/**/*.js"
|
||||
],
|
||||
"console": "externalTerminal"
|
||||
}
|
||||
]
|
||||
}
|
18
CHANGELOG.md
18
CHANGELOG.md
@ -1,18 +0,0 @@
|
||||
# Changelog
|
||||
|
||||
## 1.3.0
|
||||
|
||||
Copyright function: carry previous creation date to prevent unnecessary modifications
|
||||
|
||||
## 1.2.0
|
||||
|
||||
- Fully interactive snippets
|
||||
- db migration generator removed (new snipped in development)
|
||||
|
||||
## 1.1.0
|
||||
|
||||
Knex database migration generator
|
||||
|
||||
## 1.0.0
|
||||
|
||||
initial version
|
2
Jenkinsfile
vendored
2
Jenkinsfile
vendored
@ -5,7 +5,7 @@ pipeline {
|
||||
VERSION = VersionNumber([
|
||||
versionNumberString:
|
||||
'${BUILDS_ALL_TIME}',
|
||||
versionPrefix: '1.3.',
|
||||
versionPrefix: '1.2.',
|
||||
worstResultForIncrement: 'SUCCESS'
|
||||
])
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
# @sapphirecode/snippeteer
|
||||
|
||||
version: 1.3.x
|
||||
version: 1.2.x
|
||||
|
||||
macros for setting up projects or project parts
|
||||
|
||||
|
@ -1,10 +1,3 @@
|
||||
/*
|
||||
* 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');
|
||||
|
@ -9,18 +9,13 @@ import { CopyrightOptions } from './copyright_options';
|
||||
|
||||
export class CopyrightGenerator {
|
||||
public static get_copyright_notice (
|
||||
opt: CopyrightOptions,
|
||||
date_str?: string
|
||||
opt: CopyrightOptions
|
||||
): string {
|
||||
let notice = '';
|
||||
let date_string = date_str;
|
||||
if (typeof date_str === 'undefined') {
|
||||
const date = (new Date);
|
||||
const dtf = new Intl.DateTimeFormat ('en', { month: 'long' });
|
||||
const year = date.getFullYear ();
|
||||
const month = dtf.format (date);
|
||||
date_string = `${month} ${year}`;
|
||||
}
|
||||
const date = (new Date);
|
||||
const dtf = new Intl.DateTimeFormat ('en', { month: 'long' });
|
||||
const year = date.getFullYear ();
|
||||
const month = dtf.format (date);
|
||||
|
||||
if (opt.has_license) {
|
||||
notice = `${'/*'}
|
||||
@ -28,7 +23,7 @@ export class CopyrightGenerator {
|
||||
* This file is part of ${opt.software} which is released under ${
|
||||
opt.license}.
|
||||
* See file 'LICENSE' for full license details.
|
||||
* Created by ${opt.author} <${opt.email}>, ${date_string}
|
||||
* Created by ${opt.author} <${opt.email}>, ${month} ${year}
|
||||
*/
|
||||
|
||||
`;
|
||||
@ -36,7 +31,7 @@ export class CopyrightGenerator {
|
||||
else {
|
||||
notice = `${'/*'}
|
||||
* Copyright (C) ${opt.company || opt.author} - All Rights Reserved
|
||||
* Created by ${opt.author} <${opt.email}>, ${date_string}
|
||||
* Created by ${opt.author} <${opt.email}>, ${month} ${year}
|
||||
*/
|
||||
|
||||
`;
|
||||
|
@ -42,7 +42,9 @@ export default class Copyright implements Snippet {
|
||||
|
||||
await modify_json ((json) => {
|
||||
json.author = `${options.author} <${options.email}>`;
|
||||
json.license = options.has_license ? options.license : 'UNLICENSED';
|
||||
json.license = options.has_license
|
||||
? options.license
|
||||
: 'UNLICENSED';
|
||||
return json;
|
||||
});
|
||||
|
||||
@ -57,14 +59,11 @@ export default class Copyright implements Snippet {
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
!this._loaded_from_config
|
||||
&& (await new Confirm (
|
||||
{ message: 'should those settings be saved for the next run?' }
|
||||
)
|
||||
.run ()
|
||||
.catch (DialogHandler.catch))
|
||||
if (!this._loaded_from_config && await new Confirm (
|
||||
{ message: 'should those settings be saved for the next run?' }
|
||||
)
|
||||
.run ()
|
||||
.catch (DialogHandler.catch))
|
||||
this.save_options_file ();
|
||||
}
|
||||
|
||||
@ -82,9 +81,10 @@ export default class Copyright implements Snippet {
|
||||
this._options.software = await new Input ({ message: 'software name' })
|
||||
.run ()
|
||||
.catch (DialogHandler.catch);
|
||||
this._options.has_license = await new Confirm (
|
||||
{ message: 'would you like to specify a license?' }
|
||||
)
|
||||
this._options.has_license = await new Confirm ({
|
||||
message:
|
||||
'would you like to specify a license?'
|
||||
})
|
||||
.run ()
|
||||
.catch (DialogHandler.catch);
|
||||
if (this._options.has_license) {
|
||||
@ -104,7 +104,9 @@ export default class Copyright implements Snippet {
|
||||
this._options = null;
|
||||
|
||||
if (await fs.pathExists (file_path)) {
|
||||
const options = JSON.parse (await fs.readFile (file_path, 'utf-8'));
|
||||
const options = JSON.parse (
|
||||
await fs.readFile (file_path, 'utf-8')
|
||||
);
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.log (`author: ${options.author}
|
||||
@ -133,23 +135,21 @@ license: ${options.license}`);
|
||||
);
|
||||
}
|
||||
|
||||
private fix_file_license (data: string, filename: string): string | null {
|
||||
// eslint-disable-next-line max-len
|
||||
const regex = /\/\*\s+\*\sCopyright[\s\S]*?(?:Created by.*?, (?<date>[a-z]+ [0-9]+)[\s\S]*?|\s)\*\/\n{0,2}/gui;
|
||||
private fix_file_license (
|
||||
data: string,
|
||||
filename: string
|
||||
): string | null {
|
||||
const regex = /\/\*\s+\*\sCopyright[\s\S]*?\*\/\n{0,2}/gu;
|
||||
const shebang = /^#!.*?\n\n/gu;
|
||||
const shebang_line = shebang.exec (data);
|
||||
|
||||
if (!(/\.(?:js|ts|mjs)$/u).test (filename) && !regex.test (data))
|
||||
return null;
|
||||
const res = regex.exec (data);
|
||||
return (
|
||||
(shebang_line ? shebang_line[0] : '')
|
||||
+ CopyrightGenerator.get_copyright_notice (
|
||||
this._options as CopyrightOptions,
|
||||
res?.groups?.date
|
||||
)
|
||||
+ data.replace (regex, '')
|
||||
.replace (shebang, '')
|
||||
);
|
||||
return (shebang_line ? shebang_line[0] : '')
|
||||
+ CopyrightGenerator.get_copyright_notice (
|
||||
this._options as CopyrightOptions
|
||||
)
|
||||
+ data.replace (regex, '')
|
||||
.replace (shebang, '');
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,3 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/* eslint-disable max-len */
|
||||
export function get_readme (
|
||||
software: string,
|
||||
|
@ -1,10 +1,3 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
import { Confirm } from 'enquirer';
|
||||
import { Snippet } from '../../Snippet';
|
||||
import { modify_json, apply_template } from '../../Helper';
|
||||
|
@ -18,7 +18,6 @@
|
||||
},
|
||||
"files": [
|
||||
"/dist/",
|
||||
"/lib/",
|
||||
"LICENSE"
|
||||
],
|
||||
"author": "Timo Hocker <timo@scode.ovh>",
|
||||
|
@ -8,9 +8,9 @@
|
||||
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||
// "checkJs": true, /* Report errors in .js files. */
|
||||
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
||||
"declaration": true, /* Generates corresponding '.d.ts' file. */
|
||||
"declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
||||
"sourceMap": true, /* Generates corresponding '.map' file. */
|
||||
// "declaration": true, /* Generates corresponding '.d.ts' file. */
|
||||
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
||||
// "sourceMap": true, /* Generates corresponding '.map' file. */
|
||||
// "outFile": "./", /* Concatenate and emit output to single file. */
|
||||
"outDir": "./dist", /* Redirect output structure to the directory. */
|
||||
"rootDir": "./lib", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user