diff options
Diffstat (limited to 'desktop/node_modules/galactus/lib')
6 files changed, 110 insertions, 0 deletions
diff --git a/desktop/node_modules/galactus/lib/DestroyerOfModules.d.ts b/desktop/node_modules/galactus/lib/DestroyerOfModules.d.ts new file mode 100644 index 0000000..9142f7b --- /dev/null +++ b/desktop/node_modules/galactus/lib/DestroyerOfModules.d.ts @@ -0,0 +1,18 @@ +import { Module, Walker } from 'flora-colossus'; +export declare type ShouldKeepModuleTest = (module: Module, isDevDep: boolean) => boolean; +export declare type ModuleMap = Map<string, Module>; +export declare class DestroyerOfModules { + private walker; + private shouldKeepFn?; + constructor({ rootDirectory, walker, shouldKeepModuleTest, }: { + rootDirectory?: string; + walker?: Walker; + shouldKeepModuleTest?: ShouldKeepModuleTest; + }); + destroyModule(modulePath: string, moduleMap: ModuleMap): Promise<void>; + collectKeptModules({ relativePaths }: { + relativePaths: boolean; + }): Promise<ModuleMap>; + destroy(): Promise<void>; + private shouldKeepModule; +} diff --git a/desktop/node_modules/galactus/lib/DestroyerOfModules.js b/desktop/node_modules/galactus/lib/DestroyerOfModules.js new file mode 100644 index 0000000..f1d1a09 --- /dev/null +++ b/desktop/node_modules/galactus/lib/DestroyerOfModules.js @@ -0,0 +1,69 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DestroyerOfModules = void 0; +const fs = require("fs-extra"); +const path = require("path"); +const flora_colossus_1 = require("flora-colossus"); +class DestroyerOfModules { + constructor({ rootDirectory, walker, shouldKeepModuleTest, }) { + if (rootDirectory) { + this.walker = new flora_colossus_1.Walker(rootDirectory); + } + else if (walker) { + this.walker = walker; + } + else { + throw new Error('Must either provide rootDirectory or walker argument'); + } + if (shouldKeepModuleTest) { + this.shouldKeepFn = shouldKeepModuleTest; + } + } + async destroyModule(modulePath, moduleMap) { + const module = moduleMap.get(modulePath); + if (module) { + const nodeModulesPath = path.resolve(modulePath, 'node_modules'); + if (!await fs.pathExists(nodeModulesPath)) { + return; + } + for (const subModuleName of await fs.readdir(nodeModulesPath)) { + if (subModuleName.startsWith('@')) { + for (const subScopedModuleName of await fs.readdir(path.resolve(nodeModulesPath, subModuleName))) { + await this.destroyModule(path.resolve(nodeModulesPath, subModuleName, subScopedModuleName), moduleMap); + } + } + else { + await this.destroyModule(path.resolve(nodeModulesPath, subModuleName), moduleMap); + } + } + } + else { + await fs.remove(modulePath); + } + } + async collectKeptModules({ relativePaths = false }) { + const modules = await this.walker.walkTree(); + const moduleMap = new Map(); + const rootPath = path.resolve(this.walker.getRootModule()); + for (const module of modules) { + if (this.shouldKeepModule(module)) { + let modulePath = module.path; + if (relativePaths) { + modulePath = modulePath.replace(`${rootPath}${path.sep}`, ''); + } + moduleMap.set(modulePath, module); + } + } + return moduleMap; + } + async destroy() { + await this.destroyModule(this.walker.getRootModule(), await this.collectKeptModules({ relativePaths: false })); + } + shouldKeepModule(module) { + const isDevDep = module.depType === flora_colossus_1.DepType.DEV || module.depType === flora_colossus_1.DepType.DEV_OPTIONAL; + const shouldKeep = this.shouldKeepFn ? this.shouldKeepFn(module, isDevDep) : !isDevDep; + return shouldKeep; + } +} +exports.DestroyerOfModules = DestroyerOfModules; +//# sourceMappingURL=DestroyerOfModules.js.map
\ No newline at end of file diff --git a/desktop/node_modules/galactus/lib/DestroyerOfModules.js.map b/desktop/node_modules/galactus/lib/DestroyerOfModules.js.map new file mode 100644 index 0000000..a7cd679 --- /dev/null +++ b/desktop/node_modules/galactus/lib/DestroyerOfModules.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DestroyerOfModules.js","sourceRoot":"","sources":["../src/DestroyerOfModules.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,6BAA6B;AAE7B,mDAAyD;AAMzD,MAAa,kBAAkB;IAI7B,YAAY,EACV,aAAa,EACb,MAAM,EACN,oBAAoB,GAKrB;QACC,IAAI,aAAa,EAAE;YACjB,IAAI,CAAC,MAAM,GAAG,IAAI,uBAAM,CAAC,aAAa,CAAC,CAAC;SACzC;aAAM,IAAI,MA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,EAAE,CAAC;QAC7C,MAAM,SAAS,GAAc,IAAI,GAAG,EAAE,CAAC;QACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC;QAC3D,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;YAC5B,IAAI,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE;gBACjC,IAAI,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC;gBAC7B,IAAI,aAAa,EAAE;oBACjB,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;iBAC/D;gBACD,SAAS,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;aACnC;SACF;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,EAAE,MAAM,IAAI,CAAC,kBAAkB,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IACjH,CAAC;IAEO,gBAAgB,CAAC,MAAc;QACrC,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,KAAK,wBAAO,CAAC,GAAG,IAAI,MAAM,CAAC,OAAO,KAAK,wBAAO,CAAC,YAAY,CAAC;QAC3F,MAAM,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;QACvF,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AA/ED,gDA+EC"}
\ No newline at end of file diff --git a/desktop/node_modules/galactus/lib/index.d.ts b/desktop/node_modules/galactus/lib/index.d.ts new file mode 100644 index 0000000..f324021 --- /dev/null +++ b/desktop/node_modules/galactus/lib/index.d.ts @@ -0,0 +1,2 @@ +export * from './DestroyerOfModules'; +export * from 'flora-colossus'; diff --git a/desktop/node_modules/galactus/lib/index.js b/desktop/node_modules/galactus/lib/index.js new file mode 100644 index 0000000..4727d1c --- /dev/null +++ b/desktop/node_modules/galactus/lib/index.js @@ -0,0 +1,19 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +__exportStar(require("./DestroyerOfModules"), exports); +__exportStar(require("flora-colossus"), exports); +//# sourceMappingURL=index.js.map
\ No newline at end of file diff --git a/desktop/node_modules/galactus/lib/index.js.map b/desktop/node_modules/galactus/lib/index.js.map new file mode 100644 index 0000000..ad51e9f --- /dev/null +++ b/desktop/node_modules/galactus/lib/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,iDAA+B"}
\ No newline at end of file |