From 6d5a47292c58a1652e584c921680cd0d625efcde Mon Sep 17 00:00:00 2001 From: Karl-Philipp Wulfert Date: Thu, 17 Jan 2019 12:56:52 +0100 Subject: [PATCH] refactor: remove remnants of pack --- README.md | 8 ------- package.json | 1 - src/common.ts | 56 -------------------------------------------- src/configuration.ts | 2 -- 4 files changed, 67 deletions(-) diff --git a/README.md b/README.md index eefe682a..c45e7339 100755 --- a/README.md +++ b/README.md @@ -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 -``` diff --git a/package.json b/package.json index 561cb9f6..29ead981 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/src/common.ts b/src/common.ts index 553ba976..bd5f91f9 100644 --- a/src/common.ts +++ b/src/common.ts @@ -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 { - 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 = require(); - 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 []; -} diff --git a/src/configuration.ts b/src/configuration.ts index 590db852..1fd6f129 100644 --- a/src/configuration.ts +++ b/src/configuration.ts @@ -152,5 +152,3 @@ export const NEEDED_LABELS: Label[] = [ })); export const NOTE_PREFIX = '`openstapps/projectmanagement`'; - -export const PACK_IDENTIFIER = '/* PACKED BY @openstapps/pack */';