mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-07 05:52:57 +00:00
refactor: remove remnants of pack
This commit is contained in:
@@ -52,11 +52,3 @@ This is a small cli tool that helps to maintain the project(s).
|
|||||||
```shell
|
```shell
|
||||||
openstapps-projectmanagement --help
|
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
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -56,7 +56,6 @@
|
|||||||
"main": "lib/common.js",
|
"main": "lib/common.js",
|
||||||
"typings": "lib/common.d.ts",
|
"typings": "lib/common.d.ts",
|
||||||
"bin": {
|
"bin": {
|
||||||
"openstapps-pack": "lib/pack.cli.js",
|
|
||||||
"openstapps-projectmanagement": "lib/projectmanagement.cli.js"
|
"openstapps-projectmanagement": "lib/projectmanagement.cli.js"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import {asyncPool} from 'async-pool-native/dist/async-pool';
|
|||||||
import {readFile, unlink, writeFile} from 'fs';
|
import {readFile, unlink, writeFile} from 'fs';
|
||||||
import * as glob from 'glob';
|
import * as glob from 'glob';
|
||||||
import {promisify} from 'util';
|
import {promisify} from 'util';
|
||||||
import {PACK_IDENTIFIER} from './configuration';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiated logger
|
* Instantiated logger
|
||||||
@@ -72,58 +71,3 @@ export const writeFilePromisified = promisify(writeFile);
|
|||||||
* Promisified version of unlink
|
* Promisified version of unlink
|
||||||
*/
|
*/
|
||||||
export const unlinkPromisified = promisify(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 [];
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -152,5 +152,3 @@ export const NEEDED_LABELS: Label[] = [
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
export const NOTE_PREFIX = '`openstapps/projectmanagement`';
|
export const NOTE_PREFIX = '`openstapps/projectmanagement`';
|
||||||
|
|
||||||
export const PACK_IDENTIFIER = '/* PACKED BY @openstapps/pack */';
|
|
||||||
|
|||||||
Reference in New Issue
Block a user