@ng-atomic/schematics 4.3.2 → 4.5.0
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 +10 -3
- package/collection.json +0 -5
- package/package.json +1 -2
- package/src/_testing/build-expected-file-paths.d.ts +0 -1
- package/src/_testing/build-expected-file-paths.js +0 -12
- package/src/_testing/build-expected-file-paths.js.map +0 -1
- package/src/_testing/config.d.ts +0 -1
- package/src/_testing/config.js +0 -7
- package/src/_testing/config.js.map +0 -1
- package/src/_testing/create-app-module.d.ts +0 -3
- package/src/_testing/create-app-module.js +0 -48
- package/src/_testing/create-app-module.js.map +0 -1
- package/src/_testing/create-package.d.ts +0 -3
- package/src/_testing/create-package.js +0 -14
- package/src/_testing/create-package.js.map +0 -1
- package/src/_testing/create-workspace.d.ts +0 -42
- package/src/_testing/create-workspace.js +0 -35
- package/src/_testing/create-workspace.js.map +0 -1
- package/src/_testing/index.d.ts +0 -4
- package/src/_testing/index.js +0 -8
- package/src/_testing/index.js.map +0 -1
- package/src/gpt3/distance.d.ts +0 -4
- package/src/gpt3/distance.js +0 -64
- package/src/gpt3/distance.js.map +0 -1
- package/src/gpt3/distance.spec.ts +0 -45
- package/src/gpt3/helpers.d.ts +0 -1
- package/src/gpt3/helpers.js +0 -11
- package/src/gpt3/helpers.js.map +0 -1
- package/src/gpt3/helpers.spec.ts +0 -50
- package/src/gpt3/index.d.ts +0 -8
- package/src/gpt3/index.js +0 -43
- package/src/gpt3/index.js.map +0 -1
- package/src/gpt3/index.spec.ts +0 -155
- package/src/gpt3/prompter.d.ts +0 -22
- package/src/gpt3/prompter.js +0 -79
- package/src/gpt3/prompter.js.map +0 -1
- package/src/gpt3/prompter.spec.ts +0 -28
- package/src/gpt3/schema.json +0 -31
- package/src/gpt3/schematics-x.d.ts +0 -10
- package/src/gpt3/schematics-x.js +0 -75
- package/src/gpt3/schematics-x.js.map +0 -1
- package/src/gpt3/schematics-x.spec.ts +0 -42
package/README.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
# @NgAtomic/Schematics
|
|
2
|
+
Angular Atomic Schematics
|
|
2
3
|
|
|
3
|
-
##
|
|
4
|
+
## Installation
|
|
4
5
|
```sh
|
|
5
|
-
$ ng
|
|
6
|
-
```
|
|
6
|
+
$ ng add @ng-atomic/schematics
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
```sh
|
|
11
|
+
$ export OPEN_AI_TOKEN=<--YOUR OPEN API TOKEN-->
|
|
12
|
+
$ ng g @ng-atomic/schematics:gpt3 components/user
|
|
13
|
+
```
|
package/collection.json
CHANGED
|
@@ -57,11 +57,6 @@
|
|
|
57
57
|
"description": "Setup angular-atomic-schematics",
|
|
58
58
|
"factory": "./src/setup/index#setup",
|
|
59
59
|
"schema": "./src/ng-add/schema.json"
|
|
60
|
-
},
|
|
61
|
-
"gpt3": {
|
|
62
|
-
"description": "Generate files by GPT-3",
|
|
63
|
-
"factory": "./src/gpt3/index#gpt3",
|
|
64
|
-
"schema": "./src/gpt3/schema.json"
|
|
65
60
|
}
|
|
66
61
|
}
|
|
67
62
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ng-atomic/schematics",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"schematics": "./collection.json",
|
|
6
6
|
"ng-add": {
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
"dependencies": {},
|
|
12
12
|
"peerDependencies": {
|
|
13
13
|
"@angular/core": "^14.0.0",
|
|
14
|
-
"openai": "^3.1.0",
|
|
15
14
|
"@angular/common": "^14.0.0",
|
|
16
15
|
"@angular/router": "^14.0.0",
|
|
17
16
|
"string-template": "^1.0.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const buildExpectedFilePaths: (path: string, name: string, rootPath: string, type: string) => string[];
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildExpectedFilePaths = void 0;
|
|
4
|
-
const buildExpectedFilePaths = (path, name, rootPath, type) => [
|
|
5
|
-
`${path}/${name}.module.ts`,
|
|
6
|
-
`${path}/${name}.${type}.scss`,
|
|
7
|
-
`${path}/${name}.${type}.spec.ts`,
|
|
8
|
-
`${path}/${name}.${type}.ts`,
|
|
9
|
-
`${path}/index.ts`,
|
|
10
|
-
].map(path => `${rootPath}/src/app/${path}`);
|
|
11
|
-
exports.buildExpectedFilePaths = buildExpectedFilePaths;
|
|
12
|
-
//# sourceMappingURL=build-expected-file-paths.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build-expected-file-paths.js","sourceRoot":"","sources":["../../../../../libs/schematics/src/_testing/build-expected-file-paths.ts"],"names":[],"mappings":";;;AAAO,MAAM,sBAAsB,GAAG,CAAC,IAAY,EAAE,IAAY,EAAE,QAAgB,EAAE,IAAY,EAAE,EAAE,CAAC;IACpG,GAAG,IAAI,IAAI,IAAI,YAAY;IAC3B,GAAG,IAAI,IAAI,IAAI,IAAI,IAAI,OAAO;IAC9B,GAAG,IAAI,IAAI,IAAI,IAAI,IAAI,UAAU;IACjC,GAAG,IAAI,IAAI,IAAI,IAAI,IAAI,KAAK;IAC5B,GAAG,IAAI,WAAW;CACnB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,QAAQ,YAAY,IAAI,EAAE,CAAC,CAAC;AANhC,QAAA,sBAAsB,0BAMU"}
|
package/src/_testing/config.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const COLLECTION_PATH: string;
|
package/src/_testing/config.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.COLLECTION_PATH = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
|
-
exports.COLLECTION_PATH = path_1.default.join(__dirname, '../../collection.json');
|
|
7
|
-
//# sourceMappingURL=config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../../libs/schematics/src/_testing/config.ts"],"names":[],"mappings":";;;;AAAA,wDAAwB;AAEX,QAAA,eAAe,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,uBAAuB,CAAC,CAAC"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { UnitTestTree } from '@angular-devkit/schematics/testing';
|
|
2
|
-
export declare function createAppModule(tree: UnitTestTree, path?: string): UnitTestTree;
|
|
3
|
-
export declare function createAppModuleWithEffects(tree: UnitTestTree, path: string, effects?: string): UnitTestTree;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createAppModuleWithEffects = exports.createAppModule = void 0;
|
|
4
|
-
function createAppModule(tree, path) {
|
|
5
|
-
tree.create(path || '/src/app/app.module.ts', `
|
|
6
|
-
import { BrowserModule } from '@angular/platform-browser';
|
|
7
|
-
import { NgModule } from '@angular/core';
|
|
8
|
-
import { AppComponent } from './app.component';
|
|
9
|
-
|
|
10
|
-
@NgModule({
|
|
11
|
-
declarations: [
|
|
12
|
-
AppComponent
|
|
13
|
-
],
|
|
14
|
-
imports: [
|
|
15
|
-
BrowserModule
|
|
16
|
-
],
|
|
17
|
-
providers: [],
|
|
18
|
-
bootstrap: [AppComponent]
|
|
19
|
-
})
|
|
20
|
-
export class AppModule { }
|
|
21
|
-
`);
|
|
22
|
-
return tree;
|
|
23
|
-
}
|
|
24
|
-
exports.createAppModule = createAppModule;
|
|
25
|
-
function createAppModuleWithEffects(tree, path, effects) {
|
|
26
|
-
tree.create(path || '/src/app/app.module.ts', `
|
|
27
|
-
import { BrowserModule } from '@angular/platform-browser';
|
|
28
|
-
import { NgModule } from '@angular/core';
|
|
29
|
-
import { AppComponent } from './app.component';
|
|
30
|
-
import { EffectsModule } from '@ngrx/effects';
|
|
31
|
-
|
|
32
|
-
@NgModule({
|
|
33
|
-
declarations: [
|
|
34
|
-
AppComponent
|
|
35
|
-
],
|
|
36
|
-
imports: [
|
|
37
|
-
BrowserModule,
|
|
38
|
-
${effects}
|
|
39
|
-
],
|
|
40
|
-
providers: [],
|
|
41
|
-
bootstrap: [AppComponent]
|
|
42
|
-
})
|
|
43
|
-
export class AppModule { }
|
|
44
|
-
`);
|
|
45
|
-
return tree;
|
|
46
|
-
}
|
|
47
|
-
exports.createAppModuleWithEffects = createAppModuleWithEffects;
|
|
48
|
-
//# sourceMappingURL=create-app-module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-app-module.js","sourceRoot":"","sources":["../../../../../libs/schematics/src/_testing/create-app-module.ts"],"names":[],"mappings":";;;AAEA,SAAgB,eAAe,CAC7B,IAAkB,EAClB,IAAa;IAEb,IAAI,CAAC,MAAM,CACT,IAAI,IAAI,wBAAwB,EAChC;;;;;;;;;;;;;;;;GAgBD,CACA,CAAC;IAEF,OAAO,IAAI,CAAC;AACd,CAAC;AA1BD,0CA0BC;AAED,SAAgB,0BAA0B,CACxC,IAAkB,EAClB,IAAY,EACZ,OAAgB;IAEhB,IAAI,CAAC,MAAM,CACT,IAAI,IAAI,wBAAwB,EAChC;;;;;;;;;;;;UAYM,OAAO;;;;;;GAMd,CACA,CAAC;IAEF,OAAO,IAAI,CAAC;AACd,CAAC;AA7BD,gEA6BC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createPackageJson = exports.packagePath = void 0;
|
|
4
|
-
exports.packagePath = '/package.json';
|
|
5
|
-
function createPackageJson(prefix, pkg, tree, version = '5.2.0', packagePath = '/package.json') {
|
|
6
|
-
tree.create(packagePath, `{
|
|
7
|
-
"dependencies": {
|
|
8
|
-
"@ngrx/${pkg}": "${prefix}${version}"
|
|
9
|
-
}
|
|
10
|
-
}`);
|
|
11
|
-
return tree;
|
|
12
|
-
}
|
|
13
|
-
exports.createPackageJson = createPackageJson;
|
|
14
|
-
//# sourceMappingURL=create-package.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-package.js","sourceRoot":"","sources":["../../../../../libs/schematics/src/_testing/create-package.ts"],"names":[],"mappings":";;;AAGa,QAAA,WAAW,GAAG,eAAe,CAAC;AAE3C,SAAgB,iBAAiB,CAC/B,MAAc,EACd,GAAW,EACX,IAAkB,EAClB,OAAO,GAAG,OAAO,EACjB,WAAW,GAAG,eAAe;IAE7B,IAAI,CAAC,MAAM,CACT,WAAW,EACX;;iBAEa,GAAG,OAAO,MAAM,GAAG,OAAO;;MAErC,CACH,CAAC;IAEF,OAAO,IAAI,CAAC;AACd,CAAC;AAjBD,8CAiBC"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
|
|
2
|
-
export declare const defaultWorkspaceOptions: {
|
|
3
|
-
name: string;
|
|
4
|
-
newProjectRoot: string;
|
|
5
|
-
version: string;
|
|
6
|
-
};
|
|
7
|
-
export declare const defaultAppOptions: {
|
|
8
|
-
name: string;
|
|
9
|
-
inlineStyle: boolean;
|
|
10
|
-
inlineTemplate: boolean;
|
|
11
|
-
viewEncapsulation: string;
|
|
12
|
-
routing: boolean;
|
|
13
|
-
style: string;
|
|
14
|
-
skipTests: boolean;
|
|
15
|
-
};
|
|
16
|
-
export declare function getTestProjectPath(workspaceOptions?: any, options?: any): string;
|
|
17
|
-
export declare function createWorkspace(runner: SchematicTestRunner, host: UnitTestTree, workspaceOptions?: {
|
|
18
|
-
name: string;
|
|
19
|
-
newProjectRoot: string;
|
|
20
|
-
version: string;
|
|
21
|
-
}, options?: {
|
|
22
|
-
name: string;
|
|
23
|
-
inlineStyle: boolean;
|
|
24
|
-
inlineTemplate: boolean;
|
|
25
|
-
viewEncapsulation: string;
|
|
26
|
-
routing: boolean;
|
|
27
|
-
style: string;
|
|
28
|
-
skipTests: boolean;
|
|
29
|
-
}): Promise<UnitTestTree>;
|
|
30
|
-
export declare function createNxWorkspace(runner: SchematicTestRunner, host: UnitTestTree, workspaceOptions?: {
|
|
31
|
-
name: string;
|
|
32
|
-
newProjectRoot: string;
|
|
33
|
-
version: string;
|
|
34
|
-
}, options?: {
|
|
35
|
-
name: string;
|
|
36
|
-
inlineStyle: boolean;
|
|
37
|
-
inlineTemplate: boolean;
|
|
38
|
-
viewEncapsulation: string;
|
|
39
|
-
routing: boolean;
|
|
40
|
-
style: string;
|
|
41
|
-
skipTests: boolean;
|
|
42
|
-
}): Promise<UnitTestTree>;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createNxWorkspace = exports.createWorkspace = exports.getTestProjectPath = exports.defaultAppOptions = exports.defaultWorkspaceOptions = void 0;
|
|
4
|
-
exports.defaultWorkspaceOptions = {
|
|
5
|
-
name: 'workspace',
|
|
6
|
-
newProjectRoot: 'projects',
|
|
7
|
-
version: '6.0.0',
|
|
8
|
-
};
|
|
9
|
-
exports.defaultAppOptions = {
|
|
10
|
-
name: 'app',
|
|
11
|
-
inlineStyle: false,
|
|
12
|
-
inlineTemplate: false,
|
|
13
|
-
viewEncapsulation: 'Emulated',
|
|
14
|
-
routing: false,
|
|
15
|
-
style: 'scss',
|
|
16
|
-
skipTests: false,
|
|
17
|
-
};
|
|
18
|
-
function getTestProjectPath(workspaceOptions = exports.defaultWorkspaceOptions, options = exports.defaultAppOptions) {
|
|
19
|
-
return `/${workspaceOptions.newProjectRoot}/${options.name}`;
|
|
20
|
-
}
|
|
21
|
-
exports.getTestProjectPath = getTestProjectPath;
|
|
22
|
-
async function createWorkspace(runner, host, workspaceOptions = exports.defaultWorkspaceOptions, options = exports.defaultAppOptions) {
|
|
23
|
-
host = await runner.runExternalSchematicAsync('@schematics/angular', 'workspace', workspaceOptions).toPromise();
|
|
24
|
-
host = await runner.runExternalSchematicAsync('@schematics/angular', 'application', options, host).toPromise();
|
|
25
|
-
host = await runner.runExternalSchematicAsync('@schematics/angular', 'application', { ...options, name: 'app2' }, host).toPromise();
|
|
26
|
-
return host;
|
|
27
|
-
}
|
|
28
|
-
exports.createWorkspace = createWorkspace;
|
|
29
|
-
async function createNxWorkspace(runner, host, workspaceOptions = exports.defaultWorkspaceOptions, options = exports.defaultAppOptions) {
|
|
30
|
-
host = await runner.runExternalSchematicAsync('@nrwl/angular', 'workspace', { ...workspaceOptions, cli: 'angular' }).toPromise();
|
|
31
|
-
host = await runner.runExternalSchematicAsync('@nrwl/angular', 'application', options, host).toPromise();
|
|
32
|
-
return host;
|
|
33
|
-
}
|
|
34
|
-
exports.createNxWorkspace = createNxWorkspace;
|
|
35
|
-
//# sourceMappingURL=create-workspace.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-workspace.js","sourceRoot":"","sources":["../../../../../libs/schematics/src/_testing/create-workspace.ts"],"names":[],"mappings":";;;AAEa,QAAA,uBAAuB,GAAG;IACrC,IAAI,EAAE,WAAW;IACjB,cAAc,EAAE,UAAU;IAC1B,OAAO,EAAE,OAAO;CACjB,CAAC;AAEW,QAAA,iBAAiB,GAAG;IAC/B,IAAI,EAAE,KAAK;IACX,WAAW,EAAE,KAAK;IAClB,cAAc,EAAE,KAAK;IACrB,iBAAiB,EAAE,UAAU;IAC7B,OAAO,EAAE,KAAK;IACd,KAAK,EAAE,MAAM;IACb,SAAS,EAAE,KAAK;CACjB,CAAC;AAEF,SAAgB,kBAAkB,CAChC,mBAAwB,+BAAuB,EAC/C,UAAe,yBAAiB;IAEhC,OA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3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./build-expected-file-paths"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./config"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./create-app-module"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./create-workspace"), exports);
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/schematics/src/_testing/index.ts"],"names":[],"mappings":";;;AAAA,sEAA4C;AAC5C,mDAAyB;AACzB,8DAAoC;AACpC,6DAAmC"}
|
package/src/gpt3/distance.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare function standarization(str1: string, str2: string): [string, string];
|
|
2
|
-
export declare function calculateDistance(str1: string, str2: string): number;
|
|
3
|
-
export declare function convertByWords(str: string, words: string[]): string;
|
|
4
|
-
export declare function parseFilePath(filePath: string, characters?: string[]): string[];
|
package/src/gpt3/distance.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseFilePath = exports.convertByWords = exports.calculateDistance = exports.standarization = void 0;
|
|
4
|
-
function standarization(str1, str2) {
|
|
5
|
-
const wordSet = new Set([str1, str2].map(path => parseFilePath(path)).flat());
|
|
6
|
-
wordSet.delete('.');
|
|
7
|
-
wordSet.delete('/');
|
|
8
|
-
return [convertByWords(str1, [...wordSet]), convertByWords(str2, [...wordSet])];
|
|
9
|
-
}
|
|
10
|
-
exports.standarization = standarization;
|
|
11
|
-
function calculateDistance(str1, str2) {
|
|
12
|
-
const [s1, s2] = standarization(str1, str2);
|
|
13
|
-
return levenshteinDistance(s1, s2) + depthDistance(str1, str2);
|
|
14
|
-
}
|
|
15
|
-
exports.calculateDistance = calculateDistance;
|
|
16
|
-
const LANG_MAP = `0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_+-=[]{};:'",.<>/?|\\~\` `.split('');
|
|
17
|
-
function convertByWords(str, words) {
|
|
18
|
-
return parseFilePath(str).map(c => ~words.indexOf(c) ? LANG_MAP[words.indexOf(c)] : c).join('');
|
|
19
|
-
}
|
|
20
|
-
exports.convertByWords = convertByWords;
|
|
21
|
-
function parseFilePath(filePath, characters = ['.', '/']) {
|
|
22
|
-
const result = [];
|
|
23
|
-
let word = '';
|
|
24
|
-
for (let i = 0; i < filePath.length; i++) {
|
|
25
|
-
const char = filePath[i];
|
|
26
|
-
if (characters.includes(char)) {
|
|
27
|
-
if (word.length)
|
|
28
|
-
result.push(word);
|
|
29
|
-
result.push(char);
|
|
30
|
-
word = '';
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
word += char;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
result.push(word);
|
|
37
|
-
return result;
|
|
38
|
-
}
|
|
39
|
-
exports.parseFilePath = parseFilePath;
|
|
40
|
-
function depthDistance(str1, str2) {
|
|
41
|
-
const depth1 = str1.split('/').length;
|
|
42
|
-
const depth2 = str2.split('/').length;
|
|
43
|
-
return Math.abs(depth1 - depth2);
|
|
44
|
-
}
|
|
45
|
-
function levenshteinDistance(str1, str2) {
|
|
46
|
-
const cost = (a, b) => {
|
|
47
|
-
return a === b ? 0 : 1;
|
|
48
|
-
};
|
|
49
|
-
const d = [];
|
|
50
|
-
for (let i = 0; i <= str1.length; i++) {
|
|
51
|
-
d[i] = [];
|
|
52
|
-
d[i][0] = i;
|
|
53
|
-
}
|
|
54
|
-
for (let j = 0; j <= str2.length; j++) {
|
|
55
|
-
d[0][j] = j;
|
|
56
|
-
}
|
|
57
|
-
for (let i = 1; i <= str1.length; i++) {
|
|
58
|
-
for (let j = 1; j <= str2.length; j++) {
|
|
59
|
-
d[i][j] = Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost(str1[i - 1], str2[j - 1]));
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return d[str1.length][str2.length];
|
|
63
|
-
}
|
|
64
|
-
//# sourceMappingURL=distance.js.map
|
package/src/gpt3/distance.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"distance.js","sourceRoot":"","sources":["../../../../../libs/schematics/src/gpt3/distance.ts"],"names":[],"mappings":";;;AAAA,SAAgB,cAAc,CAAC,IAAY,EAAE,IAAY;IACvD,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9E,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACpB,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACpB,OAAO,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,cAAc,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAClF,CAAC;AALD,wCAKC;AAED,SAAgB,iBAAiB,CAAC,IAAY,EAAE,IAAY;IAC1D,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC5C,OAAO,mBAAmB,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACjE,CAAC;AAHD,8CAGC;AAED,MAAM,QAAQ,GAAG,mGAAmG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAE/H,SAAgB,cAAc,CAAC,GAAW,EAAE,KAAe;IACzD,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CA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
|
|
|
1
|
-
import { calculateDistance, convertByWords, parseFilePath, standarization } from './distance';
|
|
2
|
-
|
|
3
|
-
describe('standarization', () => {
|
|
4
|
-
it('', () => {
|
|
5
|
-
expect(standarization(
|
|
6
|
-
'/libs/example/src/lib/domain/models/first-model.ts',
|
|
7
|
-
'/libs/example/src/lib/domain/models/second-model.ts',
|
|
8
|
-
)).toEqual([
|
|
9
|
-
'/0/1/2/3/4/5/6.7',
|
|
10
|
-
'/0/1/2/3/4/5/8.7',
|
|
11
|
-
])
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
describe('calculateDistance()', () => {
|
|
16
|
-
it('', () => {
|
|
17
|
-
expect(calculateDistance(
|
|
18
|
-
'/libs/example/src/lib/domain/models/first-model.ts',
|
|
19
|
-
'/libs/example/src/lib/domain/models/second-model.ts',
|
|
20
|
-
)).toEqual(1)
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('', () => {
|
|
24
|
-
expect(calculateDistance(
|
|
25
|
-
'/libs/example/src/lib/domain/models/first-model.component.ts',
|
|
26
|
-
'/libs/example/src/lib/domain/models/second-model.module.ts',
|
|
27
|
-
)).toEqual(2)
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
describe('parseFilePath', () => {
|
|
32
|
-
it('should parse file path', () => {
|
|
33
|
-
expect(parseFilePath('/projects/app/src/app/_shared/components/example/example.component.ts')).toEqual([
|
|
34
|
-
'/', 'projects', '/', 'app', '/', 'src', '/', 'app', '/', '_shared', '/',
|
|
35
|
-
'components', '/', 'example', '/', 'example', '.', 'component', '.', 'ts'
|
|
36
|
-
]);
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
describe('convertByWords', () => {
|
|
41
|
-
xit('should convert from a string to a number', () => {
|
|
42
|
-
expect(convertByWords('this/is/test/path', ['this', 'is', 'test', 'path'])).toBe('0/1/2/3');
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
|
package/src/gpt3/helpers.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getEstimateSimilarFilePaths(path: string, files: string[]): string[];
|
package/src/gpt3/helpers.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getEstimateSimilarFilePaths = void 0;
|
|
4
|
-
const distance_1 = require("./distance");
|
|
5
|
-
function getEstimateSimilarFilePaths(path, files) {
|
|
6
|
-
const results = files.map(file => [(0, distance_1.calculateDistance)(path, file), file]);
|
|
7
|
-
const min = Math.min(...results.map(([distance]) => distance));
|
|
8
|
-
return results.filter(([distance]) => distance === min).map(([_, file]) => file);
|
|
9
|
-
}
|
|
10
|
-
exports.getEstimateSimilarFilePaths = getEstimateSimilarFilePaths;
|
|
11
|
-
//# sourceMappingURL=helpers.js.map
|
package/src/gpt3/helpers.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../libs/schematics/src/gpt3/helpers.ts"],"names":[],"mappings":";;;AAAA,yCAA+C;AAE/C,SAAgB,2BAA2B,CAAC,IAAY,EAAE,KAAe;IACvE,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAA,4BAAiB,EAAC,IAAI,EAAE,IAAI,CAAC,EAAE,IAAI,CAAqB,CAAC,CAAC;IAC7F,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC/D,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,QAAQ,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;AACnF,CAAC;AAJD,kEAIC"}
|
package/src/gpt3/helpers.spec.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { getEstimateSimilarFilePaths } from './helpers';
|
|
2
|
-
|
|
3
|
-
describe('getEstimateSimilarFilePaths', () => {
|
|
4
|
-
const FILES = [
|
|
5
|
-
'/projects/app/src/styles.scss',
|
|
6
|
-
'/projects/app/src/app/app.component.html',
|
|
7
|
-
'/projects/app/src/app/_shared/components/example/example.module.ts',
|
|
8
|
-
'/projects/app/src/app/_shared/components/example/example.component.html',
|
|
9
|
-
'/projects/app/src/app/_shared/components/example/example.component.scss',
|
|
10
|
-
'/projects/app/src/app/_shared/components/example/example.component.spec.ts',
|
|
11
|
-
'/projects/app/src/app/_shared/components/example/example.component.ts',
|
|
12
|
-
'/projects/app/src/app/_shared/components/example/example.stories.ts',
|
|
13
|
-
'/projects/app/src/app/_shared/components/example/index.ts',
|
|
14
|
-
'/projects/app/src/app/_shared/components/test/test.module.ts',
|
|
15
|
-
'/projects/app/src/app/_shared/components/test/test.component.html',
|
|
16
|
-
'/projects/app/src/app/_shared/components/test/test.component.scss',
|
|
17
|
-
'/projects/app/src/app/_shared/components/test/test.component.spec.ts',
|
|
18
|
-
'/projects/app/src/app/_shared/components/test/test.component.ts',
|
|
19
|
-
'/projects/app/src/app/_shared/components/test/test.stories.ts',
|
|
20
|
-
'/projects/app/src/app/_shared/components/test/index.ts',
|
|
21
|
-
'/libs/nm-common/src/lib/domain/models/invoice.ts',
|
|
22
|
-
'/libs/nm-common/src/lib/domain/models/contract.ts',
|
|
23
|
-
];
|
|
24
|
-
|
|
25
|
-
it('', () => {
|
|
26
|
-
const result = getEstimateSimilarFilePaths('/libs/nm-common/src/lib/domain/models/customer.ts', FILES);
|
|
27
|
-
expect(result).toEqual([
|
|
28
|
-
'/libs/nm-common/src/lib/domain/models/invoice.ts',
|
|
29
|
-
'/libs/nm-common/src/lib/domain/models/contract.ts',
|
|
30
|
-
]);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('', () => {
|
|
34
|
-
const file = '/projects/app/src/app/_shared/components/expected/expected.component.ts';
|
|
35
|
-
const files = getEstimateSimilarFilePaths(file, FILES);
|
|
36
|
-
expect(files).toEqual([
|
|
37
|
-
'/projects/app/src/app/_shared/components/example/example.component.ts',
|
|
38
|
-
'/projects/app/src/app/_shared/components/test/test.component.ts',
|
|
39
|
-
]);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('', () => {
|
|
43
|
-
const file = '/projects/app/src/app/_shared/components/expected/expected.component.html';
|
|
44
|
-
const files = getEstimateSimilarFilePaths(file, FILES);
|
|
45
|
-
expect(files).toEqual([
|
|
46
|
-
'/projects/app/src/app/_shared/components/example/example.component.html',
|
|
47
|
-
'/projects/app/src/app/_shared/components/test/test.component.html',
|
|
48
|
-
]);
|
|
49
|
-
});
|
|
50
|
-
});
|
package/src/gpt3/index.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Rule, Tree } from '@angular-devkit/schematics';
|
|
2
|
-
import { Schema } from '../atomic-component/schema';
|
|
3
|
-
export declare function getFilePaths(tree: Tree, path?: string): string[];
|
|
4
|
-
export declare function resolvePath(tree: any, options: {
|
|
5
|
-
project?: string;
|
|
6
|
-
path?: string;
|
|
7
|
-
}): Promise<string>;
|
|
8
|
-
export declare const gpt3: (options: Schema) => Rule;
|
package/src/gpt3/index.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.gpt3 = exports.resolvePath = exports.getFilePaths = void 0;
|
|
4
|
-
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
-
const workspace_1 = require("@schematics/angular/utility/workspace");
|
|
6
|
-
const path_1 = require("path");
|
|
7
|
-
const schematics_x_1 = require("./schematics-x");
|
|
8
|
-
function getFilePaths(tree, path = '/') {
|
|
9
|
-
return getFiles(tree.getDir(path)).map(p => (0, path_1.join)(path, p));
|
|
10
|
-
}
|
|
11
|
-
exports.getFilePaths = getFilePaths;
|
|
12
|
-
async function resolvePath(tree, options) {
|
|
13
|
-
const defaultPath = await (0, workspace_1.createDefaultPath)(tree, options.project);
|
|
14
|
-
return (0, path_1.join)(defaultPath, options?.path ?? '');
|
|
15
|
-
}
|
|
16
|
-
exports.resolvePath = resolvePath;
|
|
17
|
-
const gpt3 = (options) => async (tree) => {
|
|
18
|
-
options.path = await resolvePath(tree, options);
|
|
19
|
-
const files = getFilePaths(tree, options.path);
|
|
20
|
-
const path = (0, path_1.join)(tree.root.path, options.path, options.name);
|
|
21
|
-
const schematicsX = new schematics_x_1.SchematicsX();
|
|
22
|
-
const entries = await schematicsX.generate(files.map(file => tree.get(file)), path);
|
|
23
|
-
for (const entry of entries) {
|
|
24
|
-
if (!tree.exists(entry.path)) {
|
|
25
|
-
tree.create(entry.path, entry.content);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return (0, schematics_1.chain)([]);
|
|
29
|
-
};
|
|
30
|
-
exports.gpt3 = gpt3;
|
|
31
|
-
function getFiles(dir) {
|
|
32
|
-
const files = [];
|
|
33
|
-
walkDir(dir, (path, entry) => entry.subfiles.forEach(file => files.push(`${path}/${file}`)));
|
|
34
|
-
return files;
|
|
35
|
-
}
|
|
36
|
-
function walkDir(dir, callback, parent = '/') {
|
|
37
|
-
dir.subdirs.forEach(path => {
|
|
38
|
-
const entry = dir.dir(path);
|
|
39
|
-
callback((0, path_1.join)(parent, path), entry);
|
|
40
|
-
walkDir(entry, callback, (0, path_1.join)(parent, path));
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=index.js.map
|
package/src/gpt3/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/schematics/src/gpt3/index.ts"],"names":[],"mappings":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M,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;YAC5B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;SACxC;KACF;IAEF,OAAO,IAAA,kBAAK,EAAC,EAAE,CAAC,CAAC;AAClB,CAAC,CAAC;AAfW,QAAA,IAAI,QAef;AAEF,SAAS,QAAQ,CAAC,GAAa;IAC7B,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC7F,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,OAAO,CAAC,GAAa,EAAE,QAAiD,EAAE,MAAM,GAAG,GAAG;IAC7F,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACzB,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC5B,QAAQ,CAAC,IAAA,WAAI,EAAC,MAAM,EAAE,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC;QACpC,OAAO,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAA,WAAI,EAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/src/gpt3/index.spec.ts
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { createWorkspace } from '../_testing';
|
|
4
|
-
|
|
5
|
-
jest.setTimeout(300 * 1000);
|
|
6
|
-
|
|
7
|
-
const COLLECTION_PATH = path.join(__dirname, '../../collection.json');
|
|
8
|
-
|
|
9
|
-
describe('Gpt Schematics', () => {
|
|
10
|
-
const runner = new SchematicTestRunner('@ng-atomic/schematics', COLLECTION_PATH);
|
|
11
|
-
let tree: UnitTestTree;
|
|
12
|
-
|
|
13
|
-
xdescribe('Angular Workspace', () => {
|
|
14
|
-
beforeEach(async () => {
|
|
15
|
-
tree = await createWorkspace(runner, tree);
|
|
16
|
-
tree = await runner.runSchematicAsync('atomic-component', {
|
|
17
|
-
project: 'app', path: '_shared/components', name: 'example'
|
|
18
|
-
}, tree).toPromise();
|
|
19
|
-
|
|
20
|
-
tree = await runner.runSchematicAsync('atomic-component', {
|
|
21
|
-
project: 'app', path: '_shared/components', name: 'test'
|
|
22
|
-
}, tree).toPromise();
|
|
23
|
-
|
|
24
|
-
expect(tree.files).toContain('/projects/app/src/app/_shared/components/example/example.module.ts');
|
|
25
|
-
expect(tree.files).toContain('/projects/app/src/app/_shared/components/example/example.component.html');
|
|
26
|
-
expect(tree.files).toContain('/projects/app/src/app/_shared/components/example/example.component.scss');
|
|
27
|
-
expect(tree.files).toContain('/projects/app/src/app/_shared/components/example/example.component.spec.ts');
|
|
28
|
-
expect(tree.files).toContain('/projects/app/src/app/_shared/components/example/example.component.ts');
|
|
29
|
-
expect(tree.files).toContain('/projects/app/src/app/_shared/components/example/example.stories.ts');
|
|
30
|
-
expect(tree.files).toContain('/projects/app/src/app/_shared/components/example/index.ts');
|
|
31
|
-
expect(tree.files).toContain('/projects/app/src/app/_shared/components/test/test.module.ts');
|
|
32
|
-
expect(tree.files).toContain('/projects/app/src/app/_shared/components/test/test.component.html');
|
|
33
|
-
expect(tree.files).toContain('/projects/app/src/app/_shared/components/test/test.component.scss');
|
|
34
|
-
expect(tree.files).toContain('/projects/app/src/app/_shared/components/test/test.component.spec.ts');
|
|
35
|
-
expect(tree.files).toContain('/projects/app/src/app/_shared/components/test/test.component.ts');
|
|
36
|
-
expect(tree.files).toContain('/projects/app/src/app/_shared/components/test/test.stories.ts');
|
|
37
|
-
expect(tree.files).toContain('/projects/app/src/app/_shared/components/test/index.ts');
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
xit('should create atomic component files', async () => {
|
|
41
|
-
tree = await runner.runSchematicAsync('gpt3', {
|
|
42
|
-
project: 'app', path: '_shared/components', name: 'expected'
|
|
43
|
-
}, tree).toPromise();
|
|
44
|
-
// expect(tree.files).toContain('/projects/app/src/app/_shared/components/expected/expected.module.ts');
|
|
45
|
-
// expect(tree.files).toContain('/projects/app/src/app/_shared/components/expected/expected.component.html');
|
|
46
|
-
// expect(tree.files).toContain('/projects/app/src/app/_shared/components/expected/expected.component.scss');
|
|
47
|
-
// expect(tree.files).toContain('/projects/app/src/app/_shared/components/expected/expected.component.spec.ts');
|
|
48
|
-
// expect(tree.files).toContain('/projects/app/src/app/_shared/components/expected/expected.component.ts');
|
|
49
|
-
// expect(tree.files).toContain('/projects/app/src/app/_shared/components/expected/expected.stories.ts');
|
|
50
|
-
// expect(tree.files).toContain('/projects/app/src/app/_shared/components/expected/index.ts');
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
xit('should create atomic component files', async () => {
|
|
54
|
-
tree = await runner.runSchematicAsync('gpt3', {
|
|
55
|
-
project: 'app', path: '_shared/components/', name: 'expected/expected.module.ts'
|
|
56
|
-
}, tree).toPromise();
|
|
57
|
-
expect(tree.files).toContain('/projects/app/src/app/_shared/components/expected/expected.module.ts');
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('should create atomic component files', async () => {
|
|
61
|
-
tree = await runner.runSchematicAsync('gpt3', {
|
|
62
|
-
project: 'app', path: '', name: '_shared/components/expected/expected.module.ts'
|
|
63
|
-
}, tree).toPromise();
|
|
64
|
-
expect(tree.files).toContain('/projects/app/src/app/_shared/components/expected/expected.module.ts');
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const TEST = `
|
|
71
|
-
\`\`\`tree.json
|
|
72
|
-
[]
|
|
73
|
-
\`\`\`
|
|
74
|
-
`;
|
|
75
|
-
|
|
76
|
-
// describe('completeToJson', () => {
|
|
77
|
-
// xit('should convert to json', () => {
|
|
78
|
-
// expect(completeToJson(TEST)).toBeTruthy();
|
|
79
|
-
// });
|
|
80
|
-
// });
|
|
81
|
-
|
|
82
|
-
// describe('parseJsonCodeBlock', () => {
|
|
83
|
-
// it('should parse json code block', () => {
|
|
84
|
-
// expect(parseJsonCodeBlock(TEST)).toBeTruthy();
|
|
85
|
-
// });
|
|
86
|
-
// });
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const CODE_BLOCKS = `
|
|
90
|
-
\`\`\`/projects/app/src/app/_shared/components/test/test.component.ts
|
|
91
|
-
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
|
|
92
|
-
|
|
93
|
-
@Component({
|
|
94
|
-
selector: 'undefineds-test',
|
|
95
|
-
templateUrl: './test.component.html',
|
|
96
|
-
styleUrls: ['./test.component.scss'],
|
|
97
|
-
changeDetection: ChangeDetectionStrategy.OnPush
|
|
98
|
-
})
|
|
99
|
-
export class TestComponent implements OnInit {
|
|
100
|
-
|
|
101
|
-
constructor() { }
|
|
102
|
-
|
|
103
|
-
ngOnInit(): void {
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
\`\`\`
|
|
109
|
-
|
|
110
|
-
\`\`\`/projects/app/src/app/_shared/components/example/example.component.ts
|
|
111
|
-
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
|
|
112
|
-
|
|
113
|
-
@Component({
|
|
114
|
-
selector: 'undefineds-example',
|
|
115
|
-
templateUrl: './example.component.html',
|
|
116
|
-
styleUrls: ['./example.component.scss'],
|
|
117
|
-
changeDetection: ChangeDetectionStrategy.OnPush
|
|
118
|
-
})
|
|
119
|
-
export class ExampleComponent implements OnInit {
|
|
120
|
-
|
|
121
|
-
constructor() { }
|
|
122
|
-
|
|
123
|
-
ngOnInit(): void {
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
\`\`\`
|
|
129
|
-
|
|
130
|
-
\`\`\`/projects/app/src/app/_shared/components/expected/expected.component.ts
|
|
131
|
-
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
|
|
132
|
-
|
|
133
|
-
@Component({
|
|
134
|
-
selector: 'undefineds-expected',
|
|
135
|
-
templateUrl: './expected.component.html',
|
|
136
|
-
styleUrls: ['./expected.component.scss'],
|
|
137
|
-
changeDetection: ChangeDetectionStrategy.OnPush
|
|
138
|
-
})
|
|
139
|
-
export class ExpectedComponent implements OnInit {
|
|
140
|
-
|
|
141
|
-
constructor() { }
|
|
142
|
-
|
|
143
|
-
ngOnInit(): void {
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
\`\`\`
|
|
149
|
-
`;
|
|
150
|
-
|
|
151
|
-
// describe('parseCodeBlocks', () => {
|
|
152
|
-
// it('should parse code blocks', () => {
|
|
153
|
-
// expect(parseCodeBlocks(CODE_BLOCKS)).toBeTruthy();
|
|
154
|
-
// });
|
|
155
|
-
// });
|
package/src/gpt3/prompter.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { FileEntry } from "@angular-devkit/schematics";
|
|
2
|
-
export interface Options {
|
|
3
|
-
model?: 'text-curie-001' | 'code-davinci-002' | 'code-cushman-001';
|
|
4
|
-
}
|
|
5
|
-
export declare class OpenAiPrompter {
|
|
6
|
-
private _prompt;
|
|
7
|
-
private config;
|
|
8
|
-
constructor(_prompt: string);
|
|
9
|
-
private openai;
|
|
10
|
-
private stop;
|
|
11
|
-
get prompt(): string;
|
|
12
|
-
autoWrite(options?: Options): Promise<void>;
|
|
13
|
-
autoWriteUntilEnd(options?: Options, maxRepeat?: number): Promise<void>;
|
|
14
|
-
write(text: string): Promise<void>;
|
|
15
|
-
isEnd(): boolean;
|
|
16
|
-
getFileEntries(): FileEntry[];
|
|
17
|
-
getFileEntry(path: string): FileEntry | null;
|
|
18
|
-
}
|
|
19
|
-
export declare class JsonPrompter extends OpenAiPrompter {
|
|
20
|
-
parseJson(prompt: string): string[];
|
|
21
|
-
getJsonFuzzy(): string[];
|
|
22
|
-
}
|
package/src/gpt3/prompter.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.JsonPrompter = exports.OpenAiPrompter = void 0;
|
|
4
|
-
const openai_1 = require("openai");
|
|
5
|
-
class OpenAiPrompter {
|
|
6
|
-
constructor(_prompt) {
|
|
7
|
-
this._prompt = _prompt;
|
|
8
|
-
this.config = new openai_1.Configuration({ apiKey: process.env['OPEN_AI_TOKEN'] });
|
|
9
|
-
this.openai = new openai_1.OpenAIApi(this.config);
|
|
10
|
-
this.stop = '\n\`\`\`';
|
|
11
|
-
}
|
|
12
|
-
get prompt() {
|
|
13
|
-
return this._prompt;
|
|
14
|
-
}
|
|
15
|
-
async autoWrite(options) {
|
|
16
|
-
try {
|
|
17
|
-
const res = await this.openai.createCompletion({
|
|
18
|
-
model: options?.model ?? 'code-cushman-001',
|
|
19
|
-
prompt: this._prompt,
|
|
20
|
-
temperature: 0,
|
|
21
|
-
max_tokens: 512,
|
|
22
|
-
stop: this.stop,
|
|
23
|
-
});
|
|
24
|
-
this._prompt += res.data.choices?.[0].text;
|
|
25
|
-
this._prompt += res.data.choices?.[0].finish_reason === 'stop' ? this.stop : '';
|
|
26
|
-
}
|
|
27
|
-
catch (res) {
|
|
28
|
-
console.error(res.response.data.error);
|
|
29
|
-
throw new Error('OpenAI API Error');
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
async autoWriteUntilEnd(options, maxRepeat = 3) {
|
|
33
|
-
for (let i = 0; i < maxRepeat; i++) {
|
|
34
|
-
if (this.isEnd())
|
|
35
|
-
return;
|
|
36
|
-
await this.autoWrite();
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
async write(text) {
|
|
40
|
-
this._prompt += text;
|
|
41
|
-
}
|
|
42
|
-
isEnd() {
|
|
43
|
-
return this._prompt.endsWith(this.stop);
|
|
44
|
-
}
|
|
45
|
-
getFileEntries() {
|
|
46
|
-
return this._prompt.split('```').filter((_, i) => i % 2).map(code => {
|
|
47
|
-
const [path, ...lines] = code.split('\n');
|
|
48
|
-
return { path, content: Buffer.from(lines.join('\n').slice(0, -1)) };
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
getFileEntry(path) {
|
|
52
|
-
const entries = this.getFileEntries();
|
|
53
|
-
return entries.find(file => file.path === path) ?? null;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
exports.OpenAiPrompter = OpenAiPrompter;
|
|
57
|
-
class JsonPrompter extends OpenAiPrompter {
|
|
58
|
-
parseJson(prompt) {
|
|
59
|
-
return JSON.parse(prompt.match(/\`\`\`tree\.json\n([\s\S]*)\`\`\`/)?.[1]);
|
|
60
|
-
}
|
|
61
|
-
getJsonFuzzy() {
|
|
62
|
-
let text = this.prompt;
|
|
63
|
-
while (text.length) {
|
|
64
|
-
let suffixes = ['"]\n```', ']\n```', '\n```', '```', '``', '`', ''];
|
|
65
|
-
for (const suffix of suffixes) {
|
|
66
|
-
try {
|
|
67
|
-
return this.parseJson(text + suffix);
|
|
68
|
-
}
|
|
69
|
-
catch { }
|
|
70
|
-
}
|
|
71
|
-
text = text.slice(0, -1);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
exports.JsonPrompter = JsonPrompter;
|
|
76
|
-
// const results = completeToJson(`${prompt}${res.data.choices?.[0].text}`);
|
|
77
|
-
// return [...new Set(results)].filter(result => result.startsWith(dirPath));
|
|
78
|
-
// }
|
|
79
|
-
//# sourceMappingURL=prompter.js.map
|
package/src/gpt3/prompter.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prompter.js","sourceRoot":"","sources":["../../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C,mCAAmC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5E,CAAC;IAED,YAAY;QACV,IAAI,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC;QACvB,OAAM,IAAI,CAAC,MAAM,EAAE;YACjB,IAAI,QAAQ,GAAG,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;YAEpE,KAAK,MAAM,MAAM,IAAI,QAAQ,EAAE;gBAC7B,IAAI;oBAAE,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC;iBAAE;gBAAC,MAAM,GAAG;aACxD;YAED,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;SAC1B;IACH,CAAC;CAEF;AAnBD,oCAmBC;AAED,8EAA8E;AAC9E,+EAA+E;AAC/E,IAAI"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { OpenAiPrompter } from './prompter';
|
|
2
|
-
|
|
3
|
-
jest.setTimeout(3000 * 1000);
|
|
4
|
-
|
|
5
|
-
const PROMPT_JSON = `
|
|
6
|
-
\`tree.json\` is 15 lines.
|
|
7
|
-
|
|
8
|
-
\`\`\`tree.json
|
|
9
|
-
[
|
|
10
|
-
"/root/app.json",
|
|
11
|
-
`.slice(1);
|
|
12
|
-
|
|
13
|
-
describe('OpenAiPrompter', () => {
|
|
14
|
-
let prompter: OpenAiPrompter;
|
|
15
|
-
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
prompter = new OpenAiPrompter('');
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
xit('', async () => {
|
|
21
|
-
prompter.write(PROMPT_JSON);
|
|
22
|
-
await prompter.autoWriteUntilEnd();
|
|
23
|
-
const fileEntry = prompter.getFileEntry('tree.json');
|
|
24
|
-
const body = fileEntry.content.toString();
|
|
25
|
-
expect(JSON.parse(body)).toBeTruthy();
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
});
|
package/src/gpt3/schema.json
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/schema",
|
|
3
|
-
"$id": "ng-atomic-schematics-gpt3",
|
|
4
|
-
"title": "Angular Atomic Schematics GPT3",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"properties": {
|
|
7
|
-
"path": {
|
|
8
|
-
"type": "string",
|
|
9
|
-
"format": "path",
|
|
10
|
-
"description": "The path at which to create the component file, relative to the current workspace. Default is a folder with the same name as the component in the project root.",
|
|
11
|
-
"visible": false
|
|
12
|
-
},
|
|
13
|
-
"project": {
|
|
14
|
-
"type": "string",
|
|
15
|
-
"description": "The name of the project.",
|
|
16
|
-
"$default": {
|
|
17
|
-
"$source": "projectName"
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
"name": {
|
|
21
|
-
"type": "string",
|
|
22
|
-
"description": "The name of the anything.",
|
|
23
|
-
"$default": {
|
|
24
|
-
"$source": "argv",
|
|
25
|
-
"index": 0
|
|
26
|
-
},
|
|
27
|
-
"x-prompt": "What name would you like to generate?"
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
"required": []
|
|
31
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { FileEntry } from "@angular-devkit/schematics";
|
|
2
|
-
export declare class SchematicsX {
|
|
3
|
-
generate(files: FileEntry[], path: string): Promise<FileEntry[]>;
|
|
4
|
-
generateFileEntry(path: string, files?: FileEntry[]): Promise<FileEntry>;
|
|
5
|
-
_generateFileEntry(path: string, fileEntries: FileEntry[]): Promise<FileEntry>;
|
|
6
|
-
getGenerateFilePaths(filePaths: string[], generatePath: string): Promise<string[]>;
|
|
7
|
-
predicateGenerateFilePaths(filePaths: string[], generatePath: string): Promise<string[]>;
|
|
8
|
-
private _predicateGenerateFilePaths;
|
|
9
|
-
}
|
|
10
|
-
export declare function getBasePath(paths: string[]): string;
|
package/src/gpt3/schematics-x.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getBasePath = exports.SchematicsX = void 0;
|
|
4
|
-
const path_1 = require("path");
|
|
5
|
-
const helpers_1 = require("./helpers");
|
|
6
|
-
const prompter_1 = require("./prompter");
|
|
7
|
-
class SchematicsX {
|
|
8
|
-
async generate(files, path) {
|
|
9
|
-
const generateFilePaths = await this.getGenerateFilePaths(files.map(file => file.path), path);
|
|
10
|
-
console.log('Estimated! => ', generateFilePaths, '\n');
|
|
11
|
-
return Promise.all(generateFilePaths.map(filePath => {
|
|
12
|
-
return this.generateFileEntry(filePath, files);
|
|
13
|
-
}));
|
|
14
|
-
}
|
|
15
|
-
async generateFileEntry(path, files = []) {
|
|
16
|
-
const similarFilePaths = (0, helpers_1.getEstimateSimilarFilePaths)(path, files.map(file => file.path));
|
|
17
|
-
const fileEntries = files.filter(file => similarFilePaths.includes(file.path));
|
|
18
|
-
console.log(`Estimating content of '${path}' by`, similarFilePaths, '...\n');
|
|
19
|
-
return this._generateFileEntry(path, fileEntries);
|
|
20
|
-
}
|
|
21
|
-
async _generateFileEntry(path, fileEntries) {
|
|
22
|
-
const prompter = new prompter_1.OpenAiPrompter(makeFilePrompt(fileEntries, path));
|
|
23
|
-
await prompter.autoWriteUntilEnd();
|
|
24
|
-
return prompter.getFileEntry(path);
|
|
25
|
-
}
|
|
26
|
-
async getGenerateFilePaths(filePaths, generatePath) {
|
|
27
|
-
if ((0, path_1.parse)(generatePath).ext.length) {
|
|
28
|
-
return [generatePath];
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
console.log('Estimating the paths of files to be generated...\n');
|
|
32
|
-
return this.predicateGenerateFilePaths(filePaths, generatePath);
|
|
33
|
-
}
|
|
34
|
-
;
|
|
35
|
-
}
|
|
36
|
-
async predicateGenerateFilePaths(filePaths, generatePath) {
|
|
37
|
-
const baseDir = getBasePath(filePaths);
|
|
38
|
-
const _filePaths = filePaths.map(path => path.replace(baseDir, ''));
|
|
39
|
-
const _generatePath = generatePath.replace(baseDir, '');
|
|
40
|
-
const paths = await this._predicateGenerateFilePaths(_filePaths, _generatePath);
|
|
41
|
-
return paths.map(path => (0, path_1.join)(baseDir, path));
|
|
42
|
-
}
|
|
43
|
-
async _predicateGenerateFilePaths(filePaths, generatePath) {
|
|
44
|
-
const parentDir = (0, path_1.resolve)(generatePath, '..');
|
|
45
|
-
const prompt = makeDirectoryPrompt(filePaths.filter(path => path.startsWith(parentDir)), generatePath);
|
|
46
|
-
const prompter = new prompter_1.JsonPrompter(prompt);
|
|
47
|
-
await prompter.autoWrite();
|
|
48
|
-
const paths = prompter.getJsonFuzzy();
|
|
49
|
-
return [...new Set(paths)].filter(path => path.startsWith(generatePath));
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
exports.SchematicsX = SchematicsX;
|
|
53
|
-
function getBasePath(paths) {
|
|
54
|
-
const basePath = paths.reduce((acc, path) => {
|
|
55
|
-
const pathParts = path.split('/');
|
|
56
|
-
const accParts = acc.split('/');
|
|
57
|
-
const parts = pathParts.filter((part, i) => part === accParts[i]);
|
|
58
|
-
return parts.join('/');
|
|
59
|
-
}, paths[0]);
|
|
60
|
-
return basePath;
|
|
61
|
-
}
|
|
62
|
-
exports.getBasePath = getBasePath;
|
|
63
|
-
function makeDirectoryPrompt(files, name) {
|
|
64
|
-
return `\`tree.json\` has 30 lines.\n\n\`\`\`tree.json\n[\n${files.map(file => `\t\"${file}\",`).join('\n')}\n\t\"${name}`;
|
|
65
|
-
}
|
|
66
|
-
function makeFilePrompt(files, path) {
|
|
67
|
-
return `${makeFileCodeBlocks(files)}\n\n\`\`\`${path}\n`;
|
|
68
|
-
}
|
|
69
|
-
function makeFileCodeBlocks(files) {
|
|
70
|
-
return files.map(file => makeFileCodeBlock(file.path, file.content.toString())).join('\n\n');
|
|
71
|
-
}
|
|
72
|
-
function makeFileCodeBlock(name, content) {
|
|
73
|
-
return `\`\`\`${name}\n${content}\n\`\`\``;
|
|
74
|
-
}
|
|
75
|
-
//# sourceMappingURL=schematics-x.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schematics-x.js","sourceRoot":"","sources":["../../../../../libs/schematics/src/gpt3/schematics-x.ts"],"names":[],"mappings":";;;AACA,+BAA4C;AAC5C,uCAAwD;AACxD,yCAA0D;AAG1D,MAAa,WAAW;IAEtB,KAAK,CAAC,QAAQ,CAAC,KAAkB,EAAE,IAAY;QAC7C,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;QAC9F,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,iBAAiB,EAAE,IAAI,CAAC,CAAC;QAEvD,OAAO,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;YAClD,OAAO,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC,CAAC;IACN,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,IAAY,EAAE,QAAqB,EAAE;QAC3D,MAAM,gBAAgB,GAAG,IAAA,qCAA2B,EAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACzF,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,gBAAgB,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC/E,OAAO,CAAC,GAAG,CAAC,0BAA0B,IAAI,MAAM,EAAE,gBAAgB,EAAE,OAAO,CAAC,CAAC;QAC7E,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C,OAAO,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC;AAC7H,CAAC;AAED,SAAS,cAAc,CAAC,KAAkB,EAAE,IAAY;IACtD,OAAO,GAAG,kBAAkB,CAAC,KAAK,CAAC,aAAa,IAAI,IAAI,CAAC;AAC3D,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAkB;IAC5C,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC/F,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAY,EAAE,OAAe;IACtD,OAAO,SAAS,IAAI,KAAK,OAAO,UAAU,CAAC;AAC7C,CAAC"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { FileEntry } from '@angular-devkit/schematics';
|
|
2
|
-
import { SchematicsX } from './schematics-x';
|
|
3
|
-
|
|
4
|
-
const FILE_ENTRIES = [
|
|
5
|
-
{
|
|
6
|
-
path: '/projects/app/src/app/_shared/components/test/test.module.ts',
|
|
7
|
-
content: Buffer.from(`test`),
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
path: '/projects/app/src/app/_shared/components/example/example.module.ts',
|
|
11
|
-
content: Buffer.from(`example`),
|
|
12
|
-
},
|
|
13
|
-
] as FileEntry[];
|
|
14
|
-
|
|
15
|
-
describe('SchematicsX', () => {
|
|
16
|
-
let schematicsX: SchematicsX;
|
|
17
|
-
|
|
18
|
-
beforeEach(() => {
|
|
19
|
-
schematicsX = new SchematicsX();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
describe('generateFileEntry', () => {
|
|
23
|
-
it('should create', async () => {
|
|
24
|
-
const PATH = '/projects/app/src/app/_shared/components/expected/expected.module.ts';
|
|
25
|
-
const entry = await schematicsX.generateFileEntry(PATH, FILE_ENTRIES);
|
|
26
|
-
expect(entry.content.toString()).toEqual(`expected`);
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
describe('predicateGenerateFilePaths', () => {
|
|
31
|
-
it('should be succeeded', async () => {
|
|
32
|
-
const PATH = '/projects/app/src/app/_shared/components/expected';
|
|
33
|
-
const context = FILE_ENTRIES.map(entry => entry.path);
|
|
34
|
-
const paths = await schematicsX.predicateGenerateFilePaths(context, PATH);
|
|
35
|
-
expect(paths).toEqual([
|
|
36
|
-
'/projects/app/src/app/_shared/components/expected/expected.module.ts',
|
|
37
|
-
]);
|
|
38
|
-
});
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
});
|