refactor: remove remnants of pack

This commit is contained in:
Karl-Philipp Wulfert
2019-01-17 12:56:52 +01:00
parent 41a349ead5
commit 6d5a47292c
4 changed files with 0 additions and 67 deletions

View File

@@ -52,11 +52,3 @@ This is a small cli tool that helps to maintain the project(s).
```shell
openstapps-projectmanagement --help
```
## Pack
This cli tool can pack multiple JavaScript-/TypeScript-definition-files into 2 single files - one for the code and one for the definitions. This is explicitly used for the `@openstapps/core`.
```shell
openstapps-pack --help
```

View File

@@ -56,7 +56,6 @@
"main": "lib/common.js",
"typings": "lib/common.d.ts",
"bin": {
"openstapps-pack": "lib/pack.cli.js",
"openstapps-projectmanagement": "lib/projectmanagement.cli.js"
}
}

View File

@@ -19,7 +19,6 @@ import {asyncPool} from 'async-pool-native/dist/async-pool';
import {readFile, unlink, writeFile} from 'fs';
import * as glob from 'glob';
import {promisify} from 'util';
import {PACK_IDENTIFIER} from './configuration';
/**
* Instantiated logger
@@ -72,58 +71,3 @@ export const writeFilePromisified = promisify(writeFile);
* Promisified version of unlink
*/
export const unlinkPromisified = promisify(unlink);
/**
* Delete file if it exists and is packed by this script
*
* @param path Path to file to check/delete
*/
export async function deleteFileIfExistingAndPacked(path: string): Promise<void> {
try {
const buffer = await readFilePromisified(path);
const content = buffer.toString();
// check if packed by this script
if (content.indexOf(PACK_IDENTIFIER) === 0) {
logger.log('Found `' + path + '` which is packed by this script. Deleting it...');
return await unlinkPromisified(path);
}
} catch (err) {
if (err.code === 'ENOENT') {
return;
}
}
}
/**
* Get all internal dependencies from the content of a module
*
* @param moduleContent Module content to analyze
*/
export function getAllInternalDependecies(moduleContent: string): string[] {
// match all const <name> = require(<moduleName>);
const requireLines =
moduleContent.match(/^\s*(const|var) [a-z0-9_]* = require\("([^"]+)"\)|require\('([^']+)'\);$/gmi);
if (Array.isArray(requireLines)) {
return requireLines.map((requireLine) => {
const matches = requireLine.match(/require\("([^"]+)"\)|require\('([^']+)'\);$/i);
// previously matched require line does not contain a require?!
if (matches === null) {
throw new Error();
}
// return only the moduleName
return matches[1];
}).filter((moduleName) => {
// filter out internal modules beginning with './' and not ending with '.json'
return /^[.]{1,2}\/(?!.*\.json$).*$/i.test(moduleName);
}).map((internalModuleName) => {
// cut './' from the name
return internalModuleName.substring(2);
});
}
return [];
}

View File

@@ -152,5 +152,3 @@ export const NEEDED_LABELS: Label[] = [
}));
export const NOTE_PREFIX = '`openstapps/projectmanagement`';
export const PACK_IDENTIFIER = '/* PACKED BY @openstapps/pack */';