@adhd/decompile-cli 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +175 -0
- package/bin/decompile.d.ts +2 -0
- package/bin/decompile.js +89 -0
- package/bin/decompile.js.map +1 -0
- package/package.json +35 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +2 -0
- package/src/index.js.map +1 -0
- package/src/lib/extractors/index.d.ts +10 -0
- package/src/lib/extractors/index.js +228 -0
- package/src/lib/extractors/index.js.map +1 -0
- package/src/lib/extractors/local-file.d.ts +5 -0
- package/src/lib/extractors/local-file.js +22 -0
- package/src/lib/extractors/local-file.js.map +1 -0
- package/src/lib/extractors/map.d.ts +6 -0
- package/src/lib/extractors/map.js +74 -0
- package/src/lib/extractors/map.js.map +1 -0
- package/src/lib/extractors/raw-html.d.ts +7 -0
- package/src/lib/extractors/raw-html.js +93 -0
- package/src/lib/extractors/raw-html.js.map +1 -0
- package/src/lib/extractors/site.d.ts +34 -0
- package/src/lib/extractors/site.js +96 -0
- package/src/lib/extractors/site.js.map +1 -0
- package/src/lib/index.d.ts +8 -0
- package/src/lib/index.js +6 -0
- package/src/lib/index.js.map +1 -0
- package/src/lib/pipeline/index.d.ts +1 -0
- package/src/lib/pipeline/index.js +2 -0
- package/src/lib/pipeline/index.js.map +1 -0
- package/src/lib/pipeline/pipes/resolver/actions.d.ts +14 -0
- package/src/lib/pipeline/pipes/resolver/actions.js +50 -0
- package/src/lib/pipeline/pipes/resolver/actions.js.map +1 -0
- package/src/lib/pipeline/pipes/resolver/index.d.ts +1 -0
- package/src/lib/pipeline/pipes/resolver/index.js +2 -0
- package/src/lib/pipeline/pipes/resolver/index.js.map +1 -0
- package/src/lib/pipeline/stack.d.ts +23 -0
- package/src/lib/pipeline/stack.js +45 -0
- package/src/lib/pipeline/stack.js.map +1 -0
- package/src/lib/store/build.d.ts +2 -0
- package/src/lib/store/build.js +50 -0
- package/src/lib/store/build.js.map +1 -0
- package/src/lib/store/index.d.ts +92 -0
- package/src/lib/store/index.js +127 -0
- package/src/lib/store/index.js.map +1 -0
- package/src/lib/store/package.d.ts +60 -0
- package/src/lib/store/package.js +114 -0
- package/src/lib/store/package.js.map +1 -0
- package/src/lib/store/templates.d.ts +84 -0
- package/src/lib/store/templates.js +78 -0
- package/src/lib/store/templates.js.map +1 -0
- package/src/lib/store/utils.d.ts +3 -0
- package/src/lib/store/utils.js +8 -0
- package/src/lib/store/utils.js.map +1 -0
- package/src/lib/validators/index.d.ts +2 -0
- package/src/lib/validators/index.js +7 -0
- package/src/lib/validators/index.js.map +1 -0
- package/src/lib/validators/local/index.d.ts +31 -0
- package/src/lib/validators/local/index.js +93 -0
- package/src/lib/validators/local/index.js.map +1 -0
- package/src/lib/validators/local/isBase64.d.ts +2 -0
- package/src/lib/validators/local/isBase64.js +11 -0
- package/src/lib/validators/local/isBase64.js.map +1 -0
- package/src/lib/validators/local/isCSS.d.ts +2 -0
- package/src/lib/validators/local/isCSS.js +15 -0
- package/src/lib/validators/local/isCSS.js.map +1 -0
- package/src/lib/validators/local/isHTML.d.ts +2 -0
- package/src/lib/validators/local/isHTML.js +13 -0
- package/src/lib/validators/local/isHTML.js.map +1 -0
- package/src/lib/validators/local/isJS.d.ts +2 -0
- package/src/lib/validators/local/isJS.js +28 -0
- package/src/lib/validators/local/isJS.js.map +1 -0
- package/src/lib/validators/local/isJson.d.ts +2 -0
- package/src/lib/validators/local/isJson.js +40 -0
- package/src/lib/validators/local/isJson.js.map +1 -0
- package/src/lib/validators/local/isSourceMap.d.ts +11 -0
- package/src/lib/validators/local/isSourceMap.js +57 -0
- package/src/lib/validators/local/isSourceMap.js.map +1 -0
- package/src/lib/validators/url/errors.d.ts +9 -0
- package/src/lib/validators/url/errors.js +36 -0
- package/src/lib/validators/url/errors.js.map +1 -0
- package/src/lib/validators/url/index.d.ts +32 -0
- package/src/lib/validators/url/index.js +231 -0
- package/src/lib/validators/url/index.js.map +1 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import AdmZip from 'adm-zip';
|
|
2
|
+
export interface WriteOperations {
|
|
3
|
+
pending: (string | Promise<string | void>)[];
|
|
4
|
+
completed: string[];
|
|
5
|
+
}
|
|
6
|
+
interface IStore {
|
|
7
|
+
writes: WriteOperations;
|
|
8
|
+
zip: AdmZip;
|
|
9
|
+
prefix: string;
|
|
10
|
+
main_file: string;
|
|
11
|
+
}
|
|
12
|
+
declare class FileStore implements IStore {
|
|
13
|
+
static buildPackage: (project_path: string) => Promise<string[]>;
|
|
14
|
+
static getDeps: (p_paths: string[], _options?: {}, src_path?: string) => Promise<{
|
|
15
|
+
local: {
|
|
16
|
+
name: string;
|
|
17
|
+
importedBy: string[];
|
|
18
|
+
}[];
|
|
19
|
+
importedBy: Record<string, string[]>;
|
|
20
|
+
external: string[];
|
|
21
|
+
unimported: string[];
|
|
22
|
+
allImports: string[];
|
|
23
|
+
importedDeps: string[];
|
|
24
|
+
}>;
|
|
25
|
+
static cruiseDeps: (project_path: string) => Promise<{
|
|
26
|
+
'package.json': {
|
|
27
|
+
dependencies: Record<string, string>;
|
|
28
|
+
name: string;
|
|
29
|
+
description: string;
|
|
30
|
+
version: string;
|
|
31
|
+
homepage: string;
|
|
32
|
+
author: string;
|
|
33
|
+
repository: string;
|
|
34
|
+
bugs: {
|
|
35
|
+
url: string;
|
|
36
|
+
};
|
|
37
|
+
engines: {
|
|
38
|
+
node: string;
|
|
39
|
+
};
|
|
40
|
+
license: string;
|
|
41
|
+
main: string;
|
|
42
|
+
scripts: {};
|
|
43
|
+
devDependencies: {
|
|
44
|
+
'@babel/cli': string;
|
|
45
|
+
'@babel/core': string;
|
|
46
|
+
'@babel/node': string;
|
|
47
|
+
'@babel/plugin-proposal-class-properties': string;
|
|
48
|
+
'@babel/plugin-proposal-decorators': string;
|
|
49
|
+
'@babel/plugin-proposal-object-rest-spread': string;
|
|
50
|
+
'@babel/plugin-transform-async-to-generator': string;
|
|
51
|
+
'@babel/plugin-transform-modules-commonjs': string;
|
|
52
|
+
'@babel/plugin-transform-proto-to-assign': string;
|
|
53
|
+
'@babel/plugin-transform-runtime': string;
|
|
54
|
+
'@babel/polyfill': string;
|
|
55
|
+
'@babel/preset-env': string;
|
|
56
|
+
'@babel/runtime-corejs2': string;
|
|
57
|
+
'babel-core': string;
|
|
58
|
+
'babel-plugin-add-module-exports': string;
|
|
59
|
+
eslint: string;
|
|
60
|
+
'eslint-config-google': string;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
'index.js': string;
|
|
64
|
+
'.babelrc': {
|
|
65
|
+
presets: string[];
|
|
66
|
+
plugins: (string | (string | {
|
|
67
|
+
loose: boolean;
|
|
68
|
+
})[] | (string | {
|
|
69
|
+
polyfill: boolean;
|
|
70
|
+
})[])[];
|
|
71
|
+
};
|
|
72
|
+
}>;
|
|
73
|
+
index: Record<string, Record<string, number>>;
|
|
74
|
+
writes: WriteOperations;
|
|
75
|
+
zip: AdmZip;
|
|
76
|
+
prefix: string;
|
|
77
|
+
main_file: string;
|
|
78
|
+
constructor(initialPrefix?: string);
|
|
79
|
+
setPrefix(prefix_path: string, timestamp?: boolean): void;
|
|
80
|
+
pathFor(file: string): string;
|
|
81
|
+
pending(): (string | Promise<string | void>)[];
|
|
82
|
+
completed(): string[];
|
|
83
|
+
count(event: keyof WriteOperations): number;
|
|
84
|
+
private log;
|
|
85
|
+
addFile(file: string, content: string | Buffer, type?: 'dir' | 'zip'): Promise<void>;
|
|
86
|
+
addToImports(filePath: string): void;
|
|
87
|
+
flush(): Promise<(string | void)[]>;
|
|
88
|
+
finalize(): Promise<WriteOperations>;
|
|
89
|
+
}
|
|
90
|
+
declare const Store: FileStore;
|
|
91
|
+
export { FileStore, Store };
|
|
92
|
+
export default Store;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { Transform } from '@adhd/data-base-transforms';
|
|
2
|
+
import AdmZip from 'adm-zip';
|
|
3
|
+
import fse from 'fs-extra';
|
|
4
|
+
import _ from 'lodash';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import { buildPackage, cruiseDeps, getDeps } from './package.js';
|
|
7
|
+
import { BABELRC, BLANK_PACKAGE } from './templates.js';
|
|
8
|
+
import { cleanFilePath, isExternalRef } from './utils.js';
|
|
9
|
+
class FileStore {
|
|
10
|
+
constructor(initialPrefix = './build/reverse') {
|
|
11
|
+
this.index = {
|
|
12
|
+
pending: {},
|
|
13
|
+
completed: {},
|
|
14
|
+
main: {},
|
|
15
|
+
};
|
|
16
|
+
this.writes = {
|
|
17
|
+
pending: [],
|
|
18
|
+
completed: [],
|
|
19
|
+
};
|
|
20
|
+
this.zip = new AdmZip();
|
|
21
|
+
this.prefix = initialPrefix;
|
|
22
|
+
this.main_file = '';
|
|
23
|
+
}
|
|
24
|
+
setPrefix(prefix_path, timestamp = true) {
|
|
25
|
+
this.prefix = `${prefix_path}/${timestamp ? Transform.formatDate(new Date()) : ''}/src`;
|
|
26
|
+
}
|
|
27
|
+
pathFor(file) {
|
|
28
|
+
return path.join(this.prefix, cleanFilePath(file));
|
|
29
|
+
}
|
|
30
|
+
pending() {
|
|
31
|
+
return this.writes.pending;
|
|
32
|
+
}
|
|
33
|
+
completed() {
|
|
34
|
+
return this.writes.completed;
|
|
35
|
+
}
|
|
36
|
+
count(event) {
|
|
37
|
+
return this.writes[event].length;
|
|
38
|
+
}
|
|
39
|
+
log(event, data, id) {
|
|
40
|
+
console.log(`Source file ${event === 'pending' ? 'extracted' : 'written'}: ${id}`);
|
|
41
|
+
if (event === 'completed') {
|
|
42
|
+
this.writes.completed.push(data);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
this.writes[event].push(data);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
addFile(file, content, type = 'dir') {
|
|
49
|
+
const outfile = this.pathFor(file);
|
|
50
|
+
if (isExternalRef(outfile)) {
|
|
51
|
+
return Promise.resolve();
|
|
52
|
+
}
|
|
53
|
+
if (type === 'zip') {
|
|
54
|
+
if (this.index.pending[outfile]) {
|
|
55
|
+
this.index.pending[outfile] = (this.index.pending[outfile] || 0) + 1;
|
|
56
|
+
return Promise.resolve();
|
|
57
|
+
}
|
|
58
|
+
const buffer = Buffer.from(content, 'utf-8');
|
|
59
|
+
const p = this.zip.addFile(outfile, buffer);
|
|
60
|
+
this.log('pending', p.toString(), outfile);
|
|
61
|
+
return Promise.resolve();
|
|
62
|
+
}
|
|
63
|
+
if (this.index.completed[outfile]) {
|
|
64
|
+
this.index.completed[outfile] = (this.index.completed[outfile] || 0) + 1;
|
|
65
|
+
return Promise.resolve();
|
|
66
|
+
}
|
|
67
|
+
const p = fse
|
|
68
|
+
.outputFile(outfile, content)
|
|
69
|
+
.then(() => this.log('completed', p, outfile))
|
|
70
|
+
.catch((_err) => {
|
|
71
|
+
console.error(_err);
|
|
72
|
+
});
|
|
73
|
+
this.log('pending', p, outfile);
|
|
74
|
+
return p;
|
|
75
|
+
}
|
|
76
|
+
addToImports(filePath) {
|
|
77
|
+
const parts = filePath.split('.');
|
|
78
|
+
parts.pop();
|
|
79
|
+
const base = parts.join('.');
|
|
80
|
+
if (!this.index.main[filePath] &&
|
|
81
|
+
base.endsWith('index') &&
|
|
82
|
+
!base.includes('node_modules') &&
|
|
83
|
+
!base.includes('webpack')) {
|
|
84
|
+
this.main_file += `import ${_.camelCase(path.dirname(filePath))} from "./${filePath}"\n`;
|
|
85
|
+
this.index.main[filePath] = 1;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
async flush() {
|
|
89
|
+
const results = await Promise.all(this.pending());
|
|
90
|
+
console.log(`Store: extraction complete. files written ${this.count('completed')}`);
|
|
91
|
+
this.writes = {
|
|
92
|
+
pending: [],
|
|
93
|
+
completed: [],
|
|
94
|
+
};
|
|
95
|
+
return results;
|
|
96
|
+
}
|
|
97
|
+
async finalize() {
|
|
98
|
+
try {
|
|
99
|
+
await this.addFile('package.json', JSON.stringify(BLANK_PACKAGE, null, 4));
|
|
100
|
+
await this.addFile('.babelrc', JSON.stringify(BABELRC, null, 4));
|
|
101
|
+
await this.flush();
|
|
102
|
+
await this.addFile('index.js', this.main_file);
|
|
103
|
+
const deps = await buildPackage(this.prefix);
|
|
104
|
+
const uniqueDeps = _.uniq(deps).map((p) => ({ [p]: '*' }));
|
|
105
|
+
BLANK_PACKAGE.dependencies = Object.assign({}, ...uniqueDeps);
|
|
106
|
+
const packageJson = JSON.stringify(BLANK_PACKAGE, null, 4);
|
|
107
|
+
await this.addFile('package.json', packageJson);
|
|
108
|
+
await this.flush();
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
console.error(error);
|
|
112
|
+
}
|
|
113
|
+
return this.writes;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
FileStore.buildPackage = buildPackage;
|
|
117
|
+
FileStore.getDeps = getDeps;
|
|
118
|
+
FileStore.cruiseDeps = cruiseDeps;
|
|
119
|
+
// Create singleton instance
|
|
120
|
+
const Store = new FileStore();
|
|
121
|
+
// Add static methods for backward compatibility
|
|
122
|
+
// Store.buildPackage = buildPackage;
|
|
123
|
+
// Store.getDeps = getDeps;
|
|
124
|
+
// Store.cruiseDeps = cruiseDeps;
|
|
125
|
+
export { FileStore, Store };
|
|
126
|
+
export default Store;
|
|
127
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/store/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,CAAC,MAAM,QAAQ,CAAC;AACvB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM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C;QACrB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;;AAlJM,sBAAY,GAAG,YAAY,AAAf,CAAgB;AAC5B,iBAAO,GAAG,OAAO,AAAV,CAAW;AAClB,oBAAU,GAAG,UAAU,AAAb,CAAc;AAmJjC,4BAA4B;AAC5B,MAAM,KAAK,GAAG,IAAI,SAAS,EAAE,CAAC;AAE9B,gDAAgD;AAChD,qCAAqC;AACrC,2BAA2B;AAC3B,iCAAiC;AAEjC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AAC5B,eAAe,KAAK,CAAC","sourcesContent":["import { Transform } from '@adhd/data-base-transforms';\nimport AdmZip from 'adm-zip';\nimport fse from 'fs-extra';\nimport _ from 'lodash';\nimport path from 'path';\nimport { buildPackage, cruiseDeps, getDeps } from './package.js';\nimport { BABELRC, BLANK_PACKAGE } from './templates.js';\nimport { cleanFilePath, isExternalRef } from './utils.js';\n\nexport interface WriteOperations {\n pending: (string | Promise<string | void>)[];\n completed: string[];\n}\n\ninterface IStore {\n writes: WriteOperations;\n zip: AdmZip;\n prefix: string;\n main_file: string;\n}\n\nclass FileStore implements IStore {\n static buildPackage = buildPackage;\n static getDeps = getDeps;\n static cruiseDeps = cruiseDeps;\n public index: Record<string, Record<string, number>> = {\n pending: {},\n completed: {},\n main: {},\n };\n public writes: WriteOperations = {\n pending: [],\n completed: [],\n };\n public zip: AdmZip;\n public prefix: string;\n public main_file: string;\n\n constructor(initialPrefix = './build/reverse') {\n this.zip = new AdmZip();\n this.prefix = initialPrefix;\n this.main_file = '';\n }\n\n public setPrefix(prefix_path: string, timestamp = true): void {\n this.prefix = `${prefix_path}/${\n timestamp ? Transform.formatDate(new Date()) : ''\n }/src`;\n }\n\n public pathFor(file: string): string {\n return path.join(this.prefix, cleanFilePath(file));\n }\n\n public pending(): (string | Promise<string | void>)[] {\n return this.writes.pending;\n }\n\n public completed(): string[] {\n return this.writes.completed;\n }\n\n public count(event: keyof WriteOperations): number {\n return this.writes[event].length;\n }\n\n private log(\n event: keyof WriteOperations,\n data: string | Promise<string | void>,\n id: string\n ): void {\n console.log(\n `Source file ${event === 'pending' ? 'extracted' : 'written'}: ${id}`\n );\n if (event === 'completed') {\n this.writes.completed.push(data as string);\n } else {\n this.writes[event].push(data);\n }\n }\n\n public addFile(\n file: string,\n content: string | Buffer,\n type: 'dir' | 'zip' = 'dir'\n ): Promise<void> {\n const outfile = this.pathFor(file);\n\n if (isExternalRef(outfile)) {\n return Promise.resolve();\n }\n\n if (type === 'zip') {\n if (this.index.pending[outfile]) {\n this.index.pending[outfile] = (this.index.pending[outfile] || 0) + 1;\n return Promise.resolve();\n }\n const buffer = Buffer.from(content as string, 'utf-8');\n const p = this.zip.addFile(outfile, buffer);\n this.log('pending', p.toString(), outfile);\n return Promise.resolve();\n }\n if (this.index.completed[outfile]) {\n this.index.completed[outfile] = (this.index.completed[outfile] || 0) + 1;\n return Promise.resolve();\n }\n const p = fse\n .outputFile(outfile, content)\n .then((): void => this.log('completed', p, outfile))\n .catch((_err) => {\n console.error(_err);\n });\n\n this.log('pending', p, outfile);\n return p;\n }\n\n public addToImports(filePath: string): void {\n const parts = filePath.split('.');\n parts.pop();\n const base = parts.join('.');\n\n if (\n !this.index.main[filePath] &&\n base.endsWith('index') &&\n !base.includes('node_modules') &&\n !base.includes('webpack')\n ) {\n this.main_file += `import ${_.camelCase(\n path.dirname(filePath)\n )} from \"./${filePath}\"\\n`;\n this.index.main[filePath] = 1;\n }\n }\n\n public async flush(): Promise<(string | void)[]> {\n const results = await Promise.all(this.pending());\n console.log(\n `Store: extraction complete. files written ${this.count('completed')}`\n );\n this.writes = {\n pending: [],\n completed: [],\n };\n return results;\n }\n\n public async finalize(): Promise<WriteOperations> {\n try {\n await this.addFile(\n 'package.json',\n JSON.stringify(BLANK_PACKAGE, null, 4)\n );\n await this.addFile('.babelrc', JSON.stringify(BABELRC, null, 4));\n await this.flush();\n await this.addFile('index.js', this.main_file);\n\n const deps = await buildPackage(this.prefix);\n const uniqueDeps = _.uniq(deps).map((p) => ({ [p]: '*' }));\n BLANK_PACKAGE.dependencies = Object.assign({}, ...uniqueDeps);\n\n const packageJson = JSON.stringify(BLANK_PACKAGE, null, 4);\n await this.addFile('package.json', packageJson);\n await this.flush();\n } catch (error) {\n console.error(error);\n }\n return this.writes;\n }\n}\n\n// Create singleton instance\nconst Store = new FileStore();\n\n// Add static methods for backward compatibility\n// Store.buildPackage = buildPackage;\n// Store.getDeps = getDeps;\n// Store.cruiseDeps = cruiseDeps;\n\nexport { FileStore, Store };\nexport default Store;\n"]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export declare const getDeps: (p_paths: string[], _options?: {}, src_path?: string) => Promise<{
|
|
2
|
+
local: {
|
|
3
|
+
name: string;
|
|
4
|
+
importedBy: string[];
|
|
5
|
+
}[];
|
|
6
|
+
importedBy: Record<string, string[]>;
|
|
7
|
+
external: string[];
|
|
8
|
+
unimported: string[];
|
|
9
|
+
allImports: string[];
|
|
10
|
+
importedDeps: string[];
|
|
11
|
+
}>;
|
|
12
|
+
export declare const cruiseDeps: (project_path: string) => Promise<{
|
|
13
|
+
'package.json': {
|
|
14
|
+
dependencies: Record<string, string>;
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
version: string;
|
|
18
|
+
homepage: string;
|
|
19
|
+
author: string;
|
|
20
|
+
repository: string;
|
|
21
|
+
bugs: {
|
|
22
|
+
url: string;
|
|
23
|
+
};
|
|
24
|
+
engines: {
|
|
25
|
+
node: string;
|
|
26
|
+
};
|
|
27
|
+
license: string;
|
|
28
|
+
main: string;
|
|
29
|
+
scripts: {};
|
|
30
|
+
devDependencies: {
|
|
31
|
+
'@babel/cli': string;
|
|
32
|
+
'@babel/core': string;
|
|
33
|
+
'@babel/node': string;
|
|
34
|
+
'@babel/plugin-proposal-class-properties': string;
|
|
35
|
+
'@babel/plugin-proposal-decorators': string;
|
|
36
|
+
'@babel/plugin-proposal-object-rest-spread': string;
|
|
37
|
+
'@babel/plugin-transform-async-to-generator': string;
|
|
38
|
+
'@babel/plugin-transform-modules-commonjs': string;
|
|
39
|
+
'@babel/plugin-transform-proto-to-assign': string;
|
|
40
|
+
'@babel/plugin-transform-runtime': string;
|
|
41
|
+
'@babel/polyfill': string;
|
|
42
|
+
'@babel/preset-env': string;
|
|
43
|
+
'@babel/runtime-corejs2': string;
|
|
44
|
+
'babel-core': string;
|
|
45
|
+
'babel-plugin-add-module-exports': string;
|
|
46
|
+
eslint: string;
|
|
47
|
+
'eslint-config-google': string;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
'index.js': string;
|
|
51
|
+
'.babelrc': {
|
|
52
|
+
presets: string[];
|
|
53
|
+
plugins: (string | (string | {
|
|
54
|
+
loose: boolean;
|
|
55
|
+
})[] | (string | {
|
|
56
|
+
polyfill: boolean;
|
|
57
|
+
})[])[];
|
|
58
|
+
};
|
|
59
|
+
}>;
|
|
60
|
+
export declare const buildPackage: (project_path: string) => Promise<string[]>;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import depcheck from 'depcheck';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
// import { ICruiseOptions } from 'dependency-cruiser';
|
|
4
|
+
import { babelWith, entryPointWith, packageWith } from './templates.js';
|
|
5
|
+
// const { cruise: depcruise } = require("dependency-cruiser");
|
|
6
|
+
const { cruise: depcruise } = await import('dependency-cruiser');
|
|
7
|
+
// TODO: down or upgrade depcheck;
|
|
8
|
+
const hasDepType = (t = []) => {
|
|
9
|
+
return ({ dependencyTypes }) => dependencyTypes.length && new Set(dependencyTypes).has(t[0]);
|
|
10
|
+
};
|
|
11
|
+
const defaultOptions = {
|
|
12
|
+
sourceDir: '',
|
|
13
|
+
// "ignoreMatches"
|
|
14
|
+
// includeDir: false,
|
|
15
|
+
doNotFollow: {
|
|
16
|
+
dependencyTypes: [
|
|
17
|
+
'npm',
|
|
18
|
+
'npm-dev',
|
|
19
|
+
'npm-optional',
|
|
20
|
+
'npm-peer',
|
|
21
|
+
'npm-bundled',
|
|
22
|
+
'npm-no-pkg',
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
extends: 'dependency-cruiser/configs/recommended',
|
|
26
|
+
};
|
|
27
|
+
export const getDeps = async (p_paths, _options = {}, src_path = '') => {
|
|
28
|
+
const options = {
|
|
29
|
+
...defaultOptions,
|
|
30
|
+
..._options,
|
|
31
|
+
};
|
|
32
|
+
const project_path = p_paths[0];
|
|
33
|
+
const { ext, dir, base: _base } = path.parse(project_path);
|
|
34
|
+
const full_pkg_path = path.resolve(ext ? dir : project_path);
|
|
35
|
+
const full_path = path.join(full_pkg_path, src_path);
|
|
36
|
+
let pathz = ext ? [project_path] : [full_path];
|
|
37
|
+
pathz = [...pathz, ...p_paths.slice(1)];
|
|
38
|
+
// console.log(options)
|
|
39
|
+
const deps = (await depcruise(pathz, options)).output;
|
|
40
|
+
if (typeof deps !== 'object' || !deps.modules) {
|
|
41
|
+
throw new Error('No modules found in dependency cruise result');
|
|
42
|
+
}
|
|
43
|
+
let importedBy = deps.modules
|
|
44
|
+
.flatMap((m) => m.dependencies.map((d) => ({
|
|
45
|
+
name: d.module.startsWith('./') ? d.resolved : d.module,
|
|
46
|
+
origin: m.source,
|
|
47
|
+
})))
|
|
48
|
+
.reduce((r = {}, d) => {
|
|
49
|
+
r[d.name] = r[d.name] || [];
|
|
50
|
+
r[d.name].push(d.origin);
|
|
51
|
+
return r;
|
|
52
|
+
}, {});
|
|
53
|
+
deps.modules = deps.modules
|
|
54
|
+
.map((e) => ({
|
|
55
|
+
...e,
|
|
56
|
+
fpath: path.relative(full_pkg_path, path.join(importedBy[e.source]
|
|
57
|
+
? path.dirname(importedBy[e.source][0])
|
|
58
|
+
: full_pkg_path, e.source)),
|
|
59
|
+
}))
|
|
60
|
+
.map((o) => path.dirname(o.source) == '.' ? { ...o, source: o.fpath } : o);
|
|
61
|
+
importedBy = deps.modules
|
|
62
|
+
.flatMap((m) => m.dependencies.map((d) => ({
|
|
63
|
+
name: d.module.startsWith('./') ? d.resolved : d.module,
|
|
64
|
+
origin: m.source,
|
|
65
|
+
})))
|
|
66
|
+
.reduce((r = {}, d) => {
|
|
67
|
+
r[d.name] = r[d.name] || [];
|
|
68
|
+
r[d.name].push(d.origin);
|
|
69
|
+
return r;
|
|
70
|
+
}, {});
|
|
71
|
+
const allImports = deps.modules.map((e) => e.source);
|
|
72
|
+
const importedDeps = new Set(deps.modules
|
|
73
|
+
.flatMap((m) => m.dependencies.map((d) => ({
|
|
74
|
+
...d,
|
|
75
|
+
fpath: path.relative(m.source, d.resolved),
|
|
76
|
+
origin: m.source,
|
|
77
|
+
})))
|
|
78
|
+
.map((e) => e.resolved));
|
|
79
|
+
const unimported = deps.modules
|
|
80
|
+
.filter((f) => !importedDeps.has(f.source))
|
|
81
|
+
.map((e) => e.source);
|
|
82
|
+
const depFilter = hasDepType(['npm', 'unknown']);
|
|
83
|
+
// CHANGE: replace fpath with source
|
|
84
|
+
const modules = deps.modules.filter((e) => e.source.indexOf(src_path) >= 0);
|
|
85
|
+
const local = modules.map((e) => ({
|
|
86
|
+
name: e.source,
|
|
87
|
+
importedBy: importedBy[e.source],
|
|
88
|
+
}));
|
|
89
|
+
let filtered = deps.modules.flatMap((m) => m.dependencies);
|
|
90
|
+
filtered = filtered.filter(depFilter);
|
|
91
|
+
const external = Array(...new Set(filtered.filter((e) => e.module.indexOf('./') < 0).map((e) => e.module)).values());
|
|
92
|
+
return {
|
|
93
|
+
local,
|
|
94
|
+
importedBy,
|
|
95
|
+
external,
|
|
96
|
+
unimported,
|
|
97
|
+
allImports,
|
|
98
|
+
importedDeps: Array.from(importedDeps),
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
export const cruiseDeps = async (project_path) => {
|
|
102
|
+
const { external, unimported } = await getDeps([project_path], 'src');
|
|
103
|
+
return {
|
|
104
|
+
'package.json': packageWith(external),
|
|
105
|
+
'index.js': entryPointWith(unimported),
|
|
106
|
+
'.babelrc': babelWith(),
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
export const buildPackage = async (project_path) => {
|
|
110
|
+
const full_path = path.resolve(project_path);
|
|
111
|
+
const result = await depcheck(full_path, defaultOptions);
|
|
112
|
+
return Object.keys(result.missing);
|
|
113
|
+
};
|
|
114
|
+
//# sourceMappingURL=package.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.js","sourceRoot":"","sources":["../../../../src/lib/store/package.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,uDAAuD;AACvD,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACxE,+DAA+D;AAC/D,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAC;AA0CjE,kCAAkC;AAClC,MAAM,UAAU,GAAG,CAAC,IAAsB,EAAE,EAAE,EAAE;IAC9C,OAAO,CAAC,EAAE,eAAe,EAAyC,EAAE,EAAE,CACpE,eAAe,CAAC,MAAM,IAAI,IAAI,GAAG,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACjE,CAAC,CAAC;AAaF,MAAM,cAAc,GAAkB;IACpC,SAAS,EAAE,EAAE;IACb,kBAAkB;IAClB,qBAAqB;IACrB,WAAW,EAAE;QACX,eAAe,EAAE;YACf,KAAK;YACL,SAAS;YACT,cAAc;YACd,UAAU;YACV,aAAa;YACb,YAAY;SACb;KACF;IACD,OAAO,EAAE,wCAAwC;CAClD,CAAC;AACF,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,EAC1B,OAAiB,EACjB,QAAQ,GAAG,EAA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EAAE,KAAK,CAAC,CAAC;IACtE,OAAO;QACL,cAAc,EAAE,WAAW,CAAC,QAAQ,CAAC;QACrC,UAAU,EAAE,cAAc,CAAC,UAAU,CAAC;QACtC,UAAU,EAAE,SAAS,EAAE;KACxB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAAE,YAAoB,EAAqB,EAAE;IAC5E,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAC7C,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,SAAS,EAAE,cAAkC,CAAC,CAAC;IAC7E,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC,CAAC","sourcesContent":["import depcheck from 'depcheck';\nimport path from 'path';\n// import { ICruiseOptions } from 'dependency-cruiser';\nimport { babelWith, entryPointWith, packageWith } from './templates.js';\n// const { cruise: depcruise } = require(\"dependency-cruiser\");\nconst { cruise: depcruise } = await import('dependency-cruiser');\ntype DependencyEnum =\n | 'aliased-subpath-import'\n | 'aliased-tsconfig-base-url'\n | 'aliased-tsconfig-paths'\n | 'aliased-tsconfig'\n | 'aliased-webpack'\n | 'aliased-workspace'\n | 'aliased'\n | 'amd-define'\n | 'amd-require'\n | 'amd-exotic-require'\n | 'core'\n | 'deprecated'\n | 'dynamic-import'\n | 'exotic-require'\n | 'export'\n | 'import-equals'\n | 'import'\n | 'jsdoc'\n | 'jsdoc-bracket-import'\n | 'jsdoc-import-tag'\n | 'local'\n | 'localmodule'\n | 'npm-bundled'\n | 'npm-dev'\n | 'npm-no-pkg'\n | 'npm-optional'\n | 'npm-peer'\n | 'npm-unknown'\n | 'npm'\n | 'pre-compilation-only'\n | 'process-get-builtin-module'\n | 'require'\n | 'triple-slash-amd-dependency'\n | 'triple-slash-directive'\n | 'triple-slash-file-reference'\n | 'triple-slash-type-reference'\n | 'type-import'\n | 'type-only'\n | 'undetermined'\n | 'unknown';\n// TODO: down or upgrade depcheck;\nconst hasDepType = (t: DependencyEnum[] = []) => {\n return ({ dependencyTypes }: { dependencyTypes: DependencyEnum[] }) =>\n dependencyTypes.length && new Set(dependencyTypes).has(t[0]);\n};\ninterface CruiseOptions {\n sourceDir: string;\n // `dependencyTypes` was `string[]`, which is NOT assignable to\n // dependency-cruiser's `IDoNotFollowType.dependencyTypes: DependencyType[]`\n // (TS2345 — `string` is not assignable to `DependencyType`). The precise union\n // is already declared in this file as `DependencyEnum`; use it, so a typo in a\n // dependency-type name is caught here rather than silently ignored by the cruiser.\n doNotFollow?: { dependencyTypes: DependencyEnum[] };\n extends?: string;\n [key: string]: unknown;\n}\n\nconst defaultOptions: CruiseOptions = {\n sourceDir: '',\n // \"ignoreMatches\"\n // includeDir: false,\n doNotFollow: {\n dependencyTypes: [\n 'npm',\n 'npm-dev',\n 'npm-optional',\n 'npm-peer',\n 'npm-bundled',\n 'npm-no-pkg',\n ],\n },\n extends: 'dependency-cruiser/configs/recommended',\n};\nexport const getDeps = async (\n p_paths: string[],\n _options = {},\n src_path = ''\n) => {\n const options: CruiseOptions = {\n ...defaultOptions,\n ..._options,\n };\n\n const project_path = p_paths[0];\n const { ext, dir, base: _base } = path.parse(project_path);\n const full_pkg_path = path.resolve(ext ? dir : project_path);\n const full_path = path.join(full_pkg_path, src_path);\n let pathz = ext ? [project_path] : [full_path];\n pathz = [...pathz, ...p_paths.slice(1)];\n // console.log(options)\n const deps = (await depcruise(pathz, options)).output;\n\n if (typeof deps !== 'object' || !deps.modules) {\n throw new Error('No modules found in dependency cruise result');\n }\n\n let importedBy = deps.modules\n .flatMap((m) =>\n m.dependencies.map((d) => ({\n name: d.module.startsWith('./') ? d.resolved : d.module,\n origin: m.source,\n }))\n )\n .reduce((r: Record<string, string[]> = {}, d) => {\n r[d.name] = r[d.name] || [];\n r[d.name].push(d.origin);\n return r;\n }, {});\n deps.modules = deps.modules\n .map((e) => ({\n ...e,\n fpath: path.relative(\n full_pkg_path,\n path.join(\n importedBy[e.source]\n ? path.dirname(importedBy[e.source][0])\n : full_pkg_path,\n e.source\n )\n ),\n }))\n .map((o) =>\n path.dirname(o.source) == '.' ? { ...o, source: o.fpath } : o\n );\n importedBy = deps.modules\n .flatMap((m) =>\n m.dependencies.map((d) => ({\n name: d.module.startsWith('./') ? d.resolved : d.module,\n origin: m.source,\n }))\n )\n .reduce((r: Record<string, string[]> = {}, d) => {\n r[d.name] = r[d.name] || [];\n r[d.name].push(d.origin);\n return r;\n }, {});\n const allImports = deps.modules.map((e) => e.source);\n const importedDeps = new Set(\n deps.modules\n .flatMap((m) =>\n m.dependencies.map((d) => ({\n ...d,\n fpath: path.relative(m.source, d.resolved),\n origin: m.source,\n }))\n )\n .map((e) => e.resolved)\n );\n const unimported = deps.modules\n .filter((f) => !importedDeps.has(f.source))\n .map((e) => e.source);\n\n const depFilter = hasDepType(['npm', 'unknown']);\n // CHANGE: replace fpath with source\n const modules = deps.modules.filter((e) => e.source.indexOf(src_path) >= 0);\n const local = modules.map((e) => ({\n name: e.source,\n importedBy: importedBy[e.source],\n }));\n\n let filtered = deps.modules.flatMap((m) => m.dependencies);\n filtered = filtered.filter(depFilter);\n const external = Array(\n ...new Set(\n filtered.filter((e) => e.module.indexOf('./') < 0).map((e) => e.module)\n ).values()\n );\n return {\n local,\n importedBy,\n external,\n unimported,\n allImports,\n importedDeps: Array.from(importedDeps),\n };\n};\n\nexport const cruiseDeps = async (project_path: string) => {\n const { external, unimported } = await getDeps([project_path], 'src');\n return {\n 'package.json': packageWith(external),\n 'index.js': entryPointWith(unimported),\n '.babelrc': babelWith(),\n };\n};\n\nexport const buildPackage = async (project_path: string): Promise<string[]> => {\n const full_path = path.resolve(project_path);\n const result = await depcheck(full_path, defaultOptions as depcheck.Options);\n return Object.keys(result.missing);\n};\n"]}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export declare const BLANK_PACKAGE: {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
version: string;
|
|
5
|
+
homepage: string;
|
|
6
|
+
author: string;
|
|
7
|
+
repository: string;
|
|
8
|
+
bugs: {
|
|
9
|
+
url: string;
|
|
10
|
+
};
|
|
11
|
+
engines: {
|
|
12
|
+
node: string;
|
|
13
|
+
};
|
|
14
|
+
license: string;
|
|
15
|
+
main: string;
|
|
16
|
+
scripts: {};
|
|
17
|
+
dependencies: {};
|
|
18
|
+
devDependencies: {
|
|
19
|
+
'@babel/cli': string;
|
|
20
|
+
'@babel/core': string;
|
|
21
|
+
'@babel/node': string;
|
|
22
|
+
'@babel/plugin-proposal-class-properties': string;
|
|
23
|
+
'@babel/plugin-proposal-decorators': string;
|
|
24
|
+
'@babel/plugin-proposal-object-rest-spread': string;
|
|
25
|
+
'@babel/plugin-transform-async-to-generator': string;
|
|
26
|
+
'@babel/plugin-transform-modules-commonjs': string;
|
|
27
|
+
'@babel/plugin-transform-proto-to-assign': string;
|
|
28
|
+
'@babel/plugin-transform-runtime': string;
|
|
29
|
+
'@babel/polyfill': string;
|
|
30
|
+
'@babel/preset-env': string;
|
|
31
|
+
'@babel/runtime-corejs2': string;
|
|
32
|
+
'babel-core': string;
|
|
33
|
+
'babel-plugin-add-module-exports': string;
|
|
34
|
+
eslint: string;
|
|
35
|
+
'eslint-config-google': string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export declare const BABELRC: {
|
|
39
|
+
presets: string[];
|
|
40
|
+
plugins: (string | (string | {
|
|
41
|
+
loose: boolean;
|
|
42
|
+
})[] | (string | {
|
|
43
|
+
polyfill: boolean;
|
|
44
|
+
})[])[];
|
|
45
|
+
};
|
|
46
|
+
export declare const entryPointWith: (imports?: string[]) => string;
|
|
47
|
+
export declare const packageWith: (depList: string[], overrides?: {}) => {
|
|
48
|
+
dependencies: Record<string, string>;
|
|
49
|
+
name: string;
|
|
50
|
+
description: string;
|
|
51
|
+
version: string;
|
|
52
|
+
homepage: string;
|
|
53
|
+
author: string;
|
|
54
|
+
repository: string;
|
|
55
|
+
bugs: {
|
|
56
|
+
url: string;
|
|
57
|
+
};
|
|
58
|
+
engines: {
|
|
59
|
+
node: string;
|
|
60
|
+
};
|
|
61
|
+
license: string;
|
|
62
|
+
main: string;
|
|
63
|
+
scripts: {};
|
|
64
|
+
devDependencies: {
|
|
65
|
+
'@babel/cli': string;
|
|
66
|
+
'@babel/core': string;
|
|
67
|
+
'@babel/node': string;
|
|
68
|
+
'@babel/plugin-proposal-class-properties': string;
|
|
69
|
+
'@babel/plugin-proposal-decorators': string;
|
|
70
|
+
'@babel/plugin-proposal-object-rest-spread': string;
|
|
71
|
+
'@babel/plugin-transform-async-to-generator': string;
|
|
72
|
+
'@babel/plugin-transform-modules-commonjs': string;
|
|
73
|
+
'@babel/plugin-transform-proto-to-assign': string;
|
|
74
|
+
'@babel/plugin-transform-runtime': string;
|
|
75
|
+
'@babel/polyfill': string;
|
|
76
|
+
'@babel/preset-env': string;
|
|
77
|
+
'@babel/runtime-corejs2': string;
|
|
78
|
+
'babel-core': string;
|
|
79
|
+
'babel-plugin-add-module-exports': string;
|
|
80
|
+
eslint: string;
|
|
81
|
+
'eslint-config-google': string;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
export declare const babelWith: (overrides?: Partial<typeof BABELRC>) => typeof BABELRC;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
const camelize = (str) => {
|
|
2
|
+
return str.replace(/\W+(.)/g, function (match, chr) {
|
|
3
|
+
return chr.toUpperCase();
|
|
4
|
+
});
|
|
5
|
+
};
|
|
6
|
+
export const BLANK_PACKAGE = {
|
|
7
|
+
name: '@adhd',
|
|
8
|
+
description: '',
|
|
9
|
+
version: '0.0.0',
|
|
10
|
+
homepage: 'https://github.com/pseudosky/snow',
|
|
11
|
+
author: 'snow',
|
|
12
|
+
repository: 'pseudosky/snow',
|
|
13
|
+
bugs: {
|
|
14
|
+
url: 'https://github.com/pseudosky/snow/issues',
|
|
15
|
+
},
|
|
16
|
+
engines: {
|
|
17
|
+
node: '>=0.10.0',
|
|
18
|
+
},
|
|
19
|
+
license: 'MIT',
|
|
20
|
+
main: 'index.js',
|
|
21
|
+
scripts: {},
|
|
22
|
+
dependencies: {},
|
|
23
|
+
devDependencies: {
|
|
24
|
+
'@babel/cli': '^7.0.0',
|
|
25
|
+
'@babel/core': '^7.4.5',
|
|
26
|
+
'@babel/node': '^7.0.0',
|
|
27
|
+
'@babel/plugin-proposal-class-properties': '^7.0.0',
|
|
28
|
+
'@babel/plugin-proposal-decorators': '^7.0.0',
|
|
29
|
+
'@babel/plugin-proposal-object-rest-spread': '^7.0.0',
|
|
30
|
+
'@babel/plugin-transform-async-to-generator': '*',
|
|
31
|
+
'@babel/plugin-transform-modules-commonjs': '*',
|
|
32
|
+
'@babel/plugin-transform-proto-to-assign': '^7.4.4',
|
|
33
|
+
'@babel/plugin-transform-runtime': '^7.0.0',
|
|
34
|
+
'@babel/polyfill': '^7.0.0',
|
|
35
|
+
'@babel/preset-env': '^7.4.5',
|
|
36
|
+
'@babel/runtime-corejs2': '^7.0.0',
|
|
37
|
+
'babel-core': '7.0.0-bridge.0',
|
|
38
|
+
'babel-plugin-add-module-exports': '*',
|
|
39
|
+
eslint: '^5.16.0',
|
|
40
|
+
'eslint-config-google': '^0.13.0',
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
export const BABELRC = {
|
|
44
|
+
// "presets": ["stage-0", "react", "es2015"],
|
|
45
|
+
presets: ['@babel/preset-env'],
|
|
46
|
+
plugins: [
|
|
47
|
+
'@babel/plugin-proposal-decorators',
|
|
48
|
+
'@babel/plugin-transform-modules-commonjs',
|
|
49
|
+
'@babel/plugin-transform-async-to-generator',
|
|
50
|
+
['@babel/plugin-proposal-class-properties', { loose: true }],
|
|
51
|
+
['@babel/plugin-transform-runtime', { polyfill: false }],
|
|
52
|
+
],
|
|
53
|
+
};
|
|
54
|
+
const importFromPath = (file) => {
|
|
55
|
+
return `import ${camelize(file.split('/').slice(1).join('_'))} from "./${file}";`;
|
|
56
|
+
};
|
|
57
|
+
export const entryPointWith = (imports = []) => {
|
|
58
|
+
if (!imports.length) {
|
|
59
|
+
return '// Could not find an entry point for the app';
|
|
60
|
+
}
|
|
61
|
+
return imports.map(importFromPath).join('\n');
|
|
62
|
+
};
|
|
63
|
+
export const packageWith = (depList, overrides = {}) => {
|
|
64
|
+
const dependencies = depList.reduce((res = {}, p) => {
|
|
65
|
+
res[p] = '*';
|
|
66
|
+
console.log({ p });
|
|
67
|
+
return res;
|
|
68
|
+
}, {});
|
|
69
|
+
return { ...BLANK_PACKAGE, dependencies, ...overrides };
|
|
70
|
+
};
|
|
71
|
+
export const babelWith = (overrides = {}) => {
|
|
72
|
+
return {
|
|
73
|
+
...overrides,
|
|
74
|
+
plugins: [...BABELRC.plugins, ...(overrides.plugins || [])],
|
|
75
|
+
presets: [...BABELRC.presets, ...(overrides.presets || [])],
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../../src/lib/store/templates.ts"],"names":[],"mappings":"AAAA,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,EAAE;IAC/B,OAAO,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,UAAU,KAAK,EAAE,GAAG;QAChD,OAAO,GAAG,CAAC,WAAW,EAAE,CAAC;IAC3B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AACF,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,OAAO;IACb,WAAW,EAAE,EAAE;IACf,OAAO,EAAE,OAAO;IAChB,QAAQ,EAAE,mCAAmC;IAC7C,MAAM,EAAE,MAAM;IACd,UAAU,EAAE,gBAAgB;IAC5B,IAAI,EAAE;QACJ,GAAG,EAAE,0CAA0C;KAChD;IACD,OAAO,EAAE;QACP,IAAI,EAAE,UAAU;KACjB;IACD,OAAO,EAAE,KAAK;IAC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CAAC;IACD,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,OAAiB,EAAE,SAAS,GAAG,EAAE,EAAE,EAAE;IAC/D,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAA8B,EAAE,EAAE,CAAC,EAAE,EAAE;QAC1E,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;QACb,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QACnB,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;IACP,OAAO,EAAE,GAAG,aAAa,EAAE,YAAY,EAAE,GAAG,SAAS,EAAE,CAAC;AAC1D,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAEA,CAAC,SAAS,GAAG,EAAE,EAAE,EAAE;IACvC,OAAO;QACL,GAAG,SAAS;QACZ,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,SAAS,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;QAC3D,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,SAAS,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;KAC5D,CAAC;AACJ,CAAC,CAAC","sourcesContent":["const camelize = (str: string) => {\n return str.replace(/\\W+(.)/g, function (match, chr) {\n return chr.toUpperCase();\n });\n};\nexport const BLANK_PACKAGE = {\n name: '@adhd',\n description: '',\n version: '0.0.0',\n homepage: 'https://github.com/pseudosky/snow',\n author: 'snow',\n repository: 'pseudosky/snow',\n bugs: {\n url: 'https://github.com/pseudosky/snow/issues',\n },\n engines: {\n node: '>=0.10.0',\n },\n license: 'MIT',\n main: 'index.js',\n scripts: {},\n dependencies: {},\n devDependencies: {\n '@babel/cli': '^7.0.0',\n '@babel/core': '^7.4.5',\n '@babel/node': '^7.0.0',\n '@babel/plugin-proposal-class-properties': '^7.0.0',\n '@babel/plugin-proposal-decorators': '^7.0.0',\n '@babel/plugin-proposal-object-rest-spread': '^7.0.0',\n '@babel/plugin-transform-async-to-generator': '*',\n '@babel/plugin-transform-modules-commonjs': '*',\n '@babel/plugin-transform-proto-to-assign': '^7.4.4',\n '@babel/plugin-transform-runtime': '^7.0.0',\n '@babel/polyfill': '^7.0.0',\n '@babel/preset-env': '^7.4.5',\n '@babel/runtime-corejs2': '^7.0.0',\n 'babel-core': '7.0.0-bridge.0',\n 'babel-plugin-add-module-exports': '*',\n eslint: '^5.16.0',\n 'eslint-config-google': '^0.13.0',\n },\n};\n\nexport const BABELRC = {\n // \"presets\": [\"stage-0\", \"react\", \"es2015\"],\n presets: ['@babel/preset-env'],\n plugins: [\n '@babel/plugin-proposal-decorators',\n '@babel/plugin-transform-modules-commonjs',\n '@babel/plugin-transform-async-to-generator',\n ['@babel/plugin-proposal-class-properties', { loose: true }],\n ['@babel/plugin-transform-runtime', { polyfill: false }],\n ],\n};\n\nconst importFromPath = (file: string) => {\n return `import ${camelize(\n file.split('/').slice(1).join('_')\n )} from \"./${file}\";`;\n};\n\nexport const entryPointWith = (imports: string[] = []) => {\n if (!imports.length) {\n return '// Could not find an entry point for the app';\n }\n return imports.map(importFromPath).join('\\n');\n};\n\nexport const packageWith = (depList: string[], overrides = {}) => {\n const dependencies = depList.reduce((res: Record<string, string> = {}, p) => {\n res[p] = '*';\n console.log({ p });\n return res;\n }, {});\n return { ...BLANK_PACKAGE, dependencies, ...overrides };\n};\n\nexport const babelWith: (\n overrides?: Partial<typeof BABELRC>\n) => typeof BABELRC = (overrides = {}) => {\n return {\n ...overrides,\n plugins: [...BABELRC.plugins, ...(overrides.plugins || [])],\n presets: [...BABELRC.presets, ...(overrides.presets || [])],\n };\n};\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
export const read_map = (map_file) => {
|
|
3
|
+
const fileContents = fs.readFileSync(map_file, 'utf8');
|
|
4
|
+
return JSON.parse(fileContents);
|
|
5
|
+
};
|
|
6
|
+
export const cleanFilePath = (p) => p.replace(/^(\.\/)?(\.\.\/)+/gm, '').replace(/^(\.\/)?src\//, '');
|
|
7
|
+
export const isExternalRef = (f) => /(webpack\/bootstrap)|(\/external "\w+"$)/i.test(f);
|
|
8
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/lib/store/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,QAAgB,EAAE,EAAE;IAC3C,MAAM,YAAY,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACvD,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;AAClC,CAAC,CAAC;AACF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAS,EAAE,EAAE,CACzC,CAAC,CAAC,OAAO,CAAC,qBAAqB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;AACpE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAS,EAAE,EAAE,CACzC,2CAA2C,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC","sourcesContent":["import fs from 'fs';\n\nexport const read_map = (map_file: string) => {\n const fileContents = fs.readFileSync(map_file, 'utf8');\n return JSON.parse(fileContents);\n};\nexport const cleanFilePath = (p: string) =>\n p.replace(/^(\\.\\/)?(\\.\\.\\/)+/gm, '').replace(/^(\\.\\/)?src\\//, '');\nexport const isExternalRef = (f: string) =>\n /(webpack\\/bootstrap)|(\\/external \"\\w+\"$)/i.test(f);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/validators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAEhD,mBAAmB;AACnB,SAAS;AACT,WAAW;AACX,IAAI","sourcesContent":["export { default as local } from './local/index.js';\nexport { default as url } from './url/index.js';\n\n// export default {\n// url,\n// local,\n// }\n"]}
|