mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-11 04:03:34 +00:00
@@ -5,7 +5,6 @@
|
|||||||
!.editorconfig
|
!.editorconfig
|
||||||
!.gitignore
|
!.gitignore
|
||||||
!.npmignore
|
!.npmignore
|
||||||
!docs
|
|
||||||
!lib
|
!lib
|
||||||
lib/tsconfig.tsbuildinfo
|
lib/tsconfig.tsbuildinfo
|
||||||
!LICENSE
|
!LICENSE
|
||||||
|
|||||||
56
src/cli.ts
56
src/cli.ts
@@ -16,7 +16,7 @@ import chalk from 'chalk';
|
|||||||
import {execSync} from 'child_process';
|
import {execSync} from 'child_process';
|
||||||
import * as commander from 'commander';
|
import * as commander from 'commander';
|
||||||
import {copyFileSync, existsSync, readFileSync, writeFileSync} from 'fs';
|
import {copyFileSync, existsSync, readFileSync, writeFileSync} from 'fs';
|
||||||
import {resolve, sep} from 'path';
|
import {join, resolve, sep} from 'path';
|
||||||
import {cwd} from 'process';
|
import {cwd} from 'process';
|
||||||
import {isDeepStrictEqual} from 'util';
|
import {isDeepStrictEqual} from 'util';
|
||||||
import {parse, stringify} from 'yaml';
|
import {parse, stringify} from 'yaml';
|
||||||
@@ -56,6 +56,8 @@ function consoleLog(...args: string[]): void {
|
|||||||
|
|
||||||
const currentWorkingDirectory = cwd();
|
const currentWorkingDirectory = cwd();
|
||||||
|
|
||||||
|
let suggestOverwrite = false;
|
||||||
|
|
||||||
// configure commander
|
// configure commander
|
||||||
commander
|
commander
|
||||||
.version(JSON.parse(readFileSync(resolve(__dirname, '..', 'package.json')).toString()).version)
|
.version(JSON.parse(readFileSync(resolve(__dirname, '..', 'package.json')).toString()).version)
|
||||||
@@ -120,7 +122,7 @@ NEEDED_FILES.forEach((file) => {
|
|||||||
// remove templates directory for destination files
|
// remove templates directory for destination files
|
||||||
if (destinationFile.indexOf('templates') === 0) {
|
if (destinationFile.indexOf('templates') === 0) {
|
||||||
destinationFile = destinationFile.split(sep).slice(1).join(sep);
|
destinationFile = destinationFile.split(sep).slice(1).join(sep);
|
||||||
file = `templates/template-${destinationFile}`;
|
file = join('templates', `template-${destinationFile}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const source = resolve(__dirname, '..', file);
|
const source = resolve(__dirname, '..', file);
|
||||||
@@ -130,6 +132,37 @@ NEEDED_FILES.forEach((file) => {
|
|||||||
if (!existsSync(destination) || commander.replace) {
|
if (!existsSync(destination) || commander.replace) {
|
||||||
copyFileSync(source, destination);
|
copyFileSync(source, destination);
|
||||||
consoleInfo(`Copied file "${source}" to "${destination}".`);
|
consoleInfo(`Copied file "${source}" to "${destination}".`);
|
||||||
|
} else if (destinationFile === '.npmignore') {
|
||||||
|
const npmIgnore = readFileSync(destination).toString();
|
||||||
|
|
||||||
|
const ignoredPatterns = npmIgnore.split('\n');
|
||||||
|
|
||||||
|
let ignoresEverything = false;
|
||||||
|
let unignoresDocs = false;
|
||||||
|
|
||||||
|
for (const ignoredPattern of ignoredPatterns) {
|
||||||
|
if (ignoredPattern === '/*') {
|
||||||
|
ignoresEverything = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ignoredPattern === '!docs') {
|
||||||
|
unignoresDocs = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ignoresEverything) {
|
||||||
|
consoleWarn(`'.npmignore' should have '/*' as first pattern to ignore everything.`);
|
||||||
|
|
||||||
|
suggestOverwrite = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unignoresDocs) {
|
||||||
|
consoleWarn(`'.npmignore' contains '!docs' and thus the package will contain the documentation.
|
||||||
|
Please double check that this is desired behavior since the docs can become huge:
|
||||||
|
https://gitlab.com/openstapps/configuration/issues/11`);
|
||||||
|
|
||||||
|
suggestOverwrite = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -141,9 +174,11 @@ if (typeof packageJson.devDependencies === 'object' && Object.keys(packageJson.d
|
|||||||
|
|
||||||
packageJsonChanged = true;
|
packageJsonChanged = true;
|
||||||
|
|
||||||
consoleInfo(`Added NYC configuration in "${packageJsonPath}".`);
|
consoleLog(`Added NYC configuration in "${packageJsonPath}".`);
|
||||||
} else if (!isDeepStrictEqual(packageJson.nyc, NYC_CONFIGURATION)) {
|
} else if (!isDeepStrictEqual(packageJson.nyc, NYC_CONFIGURATION)) {
|
||||||
consoleLog(`NYC configuration differs from the proposed one. Please check manually...`);
|
consoleInfo(`NYC configuration in '${packageJsonPath}' differs from the proposed one. Please check manually...`);
|
||||||
|
|
||||||
|
suggestOverwrite = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,9 +198,9 @@ Object.keys(SCRIPTS).forEach((scriptName) => {
|
|||||||
|
|
||||||
packageJsonChanged = true;
|
packageJsonChanged = true;
|
||||||
|
|
||||||
consoleInfo(`Added "${scriptName}" script to "${packageJsonPath}".`);
|
consoleInfo(`Added '${scriptName}' script to '${packageJsonPath}'.`);
|
||||||
} else if (typeof scriptToCheck === 'string' && scriptToCheck !== SCRIPTS[scriptName]) {
|
} else if (typeof scriptToCheck === 'string' && scriptToCheck !== SCRIPTS[scriptName]) {
|
||||||
consoleWarn(`NPM script "${scriptName}" should be "${SCRIPTS[scriptName].replace('\n', '\\n')}".`);
|
consoleWarn(`NPM script '${scriptName}' should be "${SCRIPTS[scriptName].replace('\n', '\\n')}".`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -186,7 +221,7 @@ for (let author of execBuffer.toString().split('\n')) {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
if (!authorIsAttributed) {
|
if (!authorIsAttributed) {
|
||||||
consoleInfo(`'${author}' should be attributed as author or contributor.`);
|
consoleWarn(`'${author}' should be attributed as author or contributor.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,4 +260,9 @@ if (packageJsonChanged) {
|
|||||||
consoleLog(`Changes were written to "${packageJsonPath}".`);
|
consoleLog(`Changes were written to "${packageJsonPath}".`);
|
||||||
}
|
}
|
||||||
|
|
||||||
consoleLog('Done.');
|
if (suggestOverwrite) {
|
||||||
|
consoleInfo(`You should consider to overwrite your configuration files and check for intended derivations:
|
||||||
|
npm run check-configuration -- -r`);
|
||||||
|
}
|
||||||
|
|
||||||
|
consoleLog(`Done checking the configuration in '${path}'.`);
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
# See https://stackoverflow.com/a/29932318
|
# See https://stackoverflow.com/a/29932318
|
||||||
/*
|
/*
|
||||||
# Except these files/folders
|
# Except these files/folders
|
||||||
!docs
|
|
||||||
!lib
|
!lib
|
||||||
lib/tsconfig.tsbuildinfo
|
lib/tsconfig.tsbuildinfo
|
||||||
!LICENSE
|
!LICENSE
|
||||||
|
|||||||
Reference in New Issue
Block a user