@nstudio/angular 15.0.3 → 15.0.4-rc.1
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 +4 -2
- package/collection.json +0 -5
- package/package.json +2 -2
- package/src/schematics/elements/index.js +4 -2
- package/src/schematics/feature/index.spec.js +2 -2
- package/src/utils/ast.d.ts +9 -10
- package/src/utils/ast.js +16 -15
- package/src/utils/generator.d.ts +1 -1
- package/src/utils/generator.js +2 -2
- package/src/utils/versions.d.ts +2 -2
- package/src/utils/versions.js +3 -3
- package/src/schematics/helpers/applitools/index.d.ts +0 -2
- package/src/schematics/helpers/applitools/index.js +0 -116
- package/src/schematics/helpers/applitools/index.js.map +0 -1
- package/src/schematics/helpers/index.d.ts +0 -2
- package/src/schematics/helpers/index.js +0 -27
- package/src/schematics/helpers/index.spec.d.ts +0 -1
- package/src/schematics/helpers/index.spec.js +0 -95
- package/src/schematics/helpers/schema.json +0 -22
package/README.md
CHANGED
@@ -42,10 +42,12 @@ You are now ready to create apps:
|
|
42
42
|
nx g app
|
43
43
|
```
|
44
44
|
|
45
|
-
**NOTE:** If you encounter any issue, you can try creating an Nx workspace with version specified
|
45
|
+
**NOTE:** If you encounter any issue, you can try creating an Nx workspace with a version specified.
|
46
|
+
|
47
|
+
We have tested with the following, for example:
|
46
48
|
|
47
49
|
```
|
48
|
-
npx create-nx-workspace@
|
50
|
+
npx create-nx-workspace@15.9.2
|
49
51
|
```
|
50
52
|
|
51
53
|
## App generation examples
|
package/collection.json
CHANGED
@@ -54,11 +54,6 @@
|
|
54
54
|
"schema": "./src/schematics/elements/schema.json",
|
55
55
|
"description": "Create custom elements for the web with Angular."
|
56
56
|
},
|
57
|
-
"helpers": {
|
58
|
-
"factory": "./src/schematics/helpers",
|
59
|
-
"schema": "./src/schematics/helpers/schema.json",
|
60
|
-
"description": "Helpers for Angular."
|
61
|
-
},
|
62
57
|
"xplat": {
|
63
58
|
"factory": "./src/schematics/xplat",
|
64
59
|
"schema": "./src/schematics/xplat/schema.json",
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nstudio/angular",
|
3
|
-
"version": "15.0.
|
3
|
+
"version": "15.0.4-rc.1",
|
4
4
|
"description": "Angular Plugin for xplat",
|
5
5
|
"homepage": "https://nstudio.io/xplat",
|
6
6
|
"repository": {
|
@@ -32,6 +32,6 @@
|
|
32
32
|
"@nrwl/angular": "^15.0.0"
|
33
33
|
},
|
34
34
|
"peerDependencies": {
|
35
|
-
"@nstudio/xplat": "15.0.
|
35
|
+
"@nstudio/xplat": "15.0.4-rc.1"
|
36
36
|
}
|
37
37
|
}
|
@@ -4,6 +4,7 @@ const schematics_1 = require("@angular-devkit/schematics");
|
|
4
4
|
const workspace_1 = require("@nrwl/workspace");
|
5
5
|
const xplat_1 = require("@nstudio/xplat");
|
6
6
|
const xplat_utils_1 = require("@nstudio/xplat-utils");
|
7
|
+
const devkit_1 = require("@nrwl/devkit");
|
7
8
|
let customElementList;
|
8
9
|
let componentSymbols;
|
9
10
|
let componentSymbolList;
|
@@ -170,7 +171,8 @@ function addFiles(options, extra = '') {
|
|
170
171
|
])));
|
171
172
|
}
|
172
173
|
function updateWorkspaceSupport(options, tree, context) {
|
173
|
-
|
174
|
+
const nxTree = (0, xplat_1.convertNgTreeToDevKit)(tree, context);
|
175
|
+
(0, devkit_1.updateJson)(nxTree, 'package.json', (json) => {
|
174
176
|
json.scripts = json.scripts || {};
|
175
177
|
json.dependencies = json.dependencies || {};
|
176
178
|
const angularVersion = json.dependencies['@angular/core'];
|
@@ -178,7 +180,7 @@ function updateWorkspaceSupport(options, tree, context) {
|
|
178
180
|
json.devDependencies = json.devDependencies || {};
|
179
181
|
json.devDependencies = Object.assign(Object.assign({}, json.devDependencies), { 'http-server': '^14.1.1', 'ngx-build-plus': '^15.0.0' });
|
180
182
|
return json;
|
181
|
-
})
|
183
|
+
});
|
182
184
|
}
|
183
185
|
function createCustomElementList(componentSymbols) {
|
184
186
|
const customElements = ['let component;'];
|
@@ -11,8 +11,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
12
|
exports.sandboxHomeSetup = void 0;
|
13
13
|
const schematics_1 = require("@angular-devkit/schematics");
|
14
|
-
const workspace_1 = require("@nrwl/workspace");
|
15
14
|
const testing_1 = require("@nstudio/xplat/testing");
|
15
|
+
const xplat_utils_1 = require("@nstudio/xplat-utils");
|
16
16
|
const testing_2 = require("../../utils/testing");
|
17
17
|
describe('feature schematic', () => {
|
18
18
|
let appTree;
|
@@ -324,7 +324,7 @@ describe('feature schematic', () => {
|
|
324
324
|
appTree = (0, testing_1.createXplatWithNativeScriptWeb)(appTree, true);
|
325
325
|
// manually update home.component to prep for sandobx
|
326
326
|
const homeCmpPath = `/apps/nativescript-viewer/src/features/home/components/home.component.html`;
|
327
|
-
(0,
|
327
|
+
(0, xplat_utils_1.updateFile)(appTree, homeCmpPath, sandboxHomeSetup());
|
328
328
|
// console.log('homecmp:', getFileContent(tree, homeCmpPath));
|
329
329
|
options.onlyProject = true;
|
330
330
|
options.adjustSandbox = true;
|
package/src/utils/ast.d.ts
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
import * as ts from 'typescript';
|
2
|
-
import { Change } from '@nrwl/workspace/src/utils/ast-utils';
|
3
2
|
import { Tree } from '@angular-devkit/schematics';
|
4
|
-
export declare function addToCollection(source: ts.SourceFile, barrelIndexPath: string, symbolName: string, insertSpaces?: string):
|
5
|
-
export declare function addSymbolToNgModuleMetadata(source: ts.SourceFile, ngModulePath: string, metadataField: string, expression: string):
|
6
|
-
export declare function removeFromNgModule(source: ts.SourceFile, modulePath: string, property: string):
|
7
|
-
export declare function addImportToModule(source: ts.SourceFile, modulePath: string, symbolName: string):
|
8
|
-
export declare function addImportToTestBed(source: ts.SourceFile, specPath: string, symbolName: string):
|
3
|
+
export declare function addToCollection(source: ts.SourceFile, barrelIndexPath: string, symbolName: string, insertSpaces?: string): any[];
|
4
|
+
export declare function addSymbolToNgModuleMetadata(source: ts.SourceFile, ngModulePath: string, metadataField: string, expression: string): any[];
|
5
|
+
export declare function removeFromNgModule(source: ts.SourceFile, modulePath: string, property: string): any[];
|
6
|
+
export declare function addImportToModule(source: ts.SourceFile, modulePath: string, symbolName: string): any[];
|
7
|
+
export declare function addImportToTestBed(source: ts.SourceFile, specPath: string, symbolName: string): any[];
|
9
8
|
export declare function getBootstrapComponent(source: ts.SourceFile, moduleClassName: string): string;
|
10
|
-
export declare function addRoute(ngModulePath: string, source: ts.SourceFile, route: string):
|
11
|
-
export declare function addProviderToModule(source: ts.SourceFile, modulePath: string, symbolName: string):
|
12
|
-
export declare function addDeclarationToModule(source: ts.SourceFile, modulePath: string, symbolName: string):
|
13
|
-
export declare function addEntryComponents(source: ts.SourceFile, modulePath: string, symbolName: string):
|
9
|
+
export declare function addRoute(ngModulePath: string, source: ts.SourceFile, route: string): any[];
|
10
|
+
export declare function addProviderToModule(source: ts.SourceFile, modulePath: string, symbolName: string): any[];
|
11
|
+
export declare function addDeclarationToModule(source: ts.SourceFile, modulePath: string, symbolName: string): any[];
|
12
|
+
export declare function addEntryComponents(source: ts.SourceFile, modulePath: string, symbolName: string): any[];
|
14
13
|
export declare function readBootstrapInfo(host: Tree, app: string): {
|
15
14
|
moduleSpec: string;
|
16
15
|
modulePath: string;
|
package/src/utils/ast.js
CHANGED
@@ -2,9 +2,10 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.getDecoratorPropertyValueNode = exports.readBootstrapInfo = exports.addEntryComponents = exports.addDeclarationToModule = exports.addProviderToModule = exports.addRoute = exports.getBootstrapComponent = exports.addImportToTestBed = exports.addImportToModule = exports.removeFromNgModule = exports.addSymbolToNgModuleMetadata = exports.addToCollection = void 0;
|
4
4
|
const ts = require("typescript");
|
5
|
-
const
|
5
|
+
const typescript_1 = require("nx/src/utils/typescript");
|
6
6
|
const path = require("path");
|
7
7
|
const xplat_utils_1 = require("@nstudio/xplat-utils");
|
8
|
+
const xplat_1 = require("@nstudio/xplat");
|
8
9
|
function addToCollection(source, barrelIndexPath, symbolName, insertSpaces = '') {
|
9
10
|
const collection = getCollection(source);
|
10
11
|
if (!collection)
|
@@ -12,17 +13,17 @@ function addToCollection(source, barrelIndexPath, symbolName, insertSpaces = '')
|
|
12
13
|
// if (!collection) return [new NoopChange()];
|
13
14
|
// return [new NoopChange()];
|
14
15
|
if (collection.hasTrailingComma || collection.length === 0) {
|
15
|
-
return [new
|
16
|
+
return [new xplat_1.InsertChange(barrelIndexPath, collection.end, symbolName)];
|
16
17
|
}
|
17
18
|
else {
|
18
19
|
return [
|
19
|
-
new
|
20
|
+
new xplat_1.InsertChange(barrelIndexPath, collection.end, `,\n${insertSpaces}${symbolName}`),
|
20
21
|
];
|
21
22
|
}
|
22
23
|
}
|
23
24
|
exports.addToCollection = addToCollection;
|
24
25
|
function getCollection(source) {
|
25
|
-
const allCollections = (0,
|
26
|
+
const allCollections = (0, typescript_1.findNodes)(source, ts.SyntaxKind.ArrayLiteralExpression);
|
26
27
|
// console.log('allCollections:', allCollections);
|
27
28
|
// allCollections.forEach((i: ts.ArrayLiteralExpression) => {
|
28
29
|
// console.log('getText:',i.getText());
|
@@ -79,7 +80,7 @@ function _angularImportsFromNode(node, _sourceFile) {
|
|
79
80
|
}
|
80
81
|
}
|
81
82
|
function getDecoratorMetadata(source, identifier, module) {
|
82
|
-
const angularImports = (0,
|
83
|
+
const angularImports = (0, typescript_1.findNodes)(source, ts.SyntaxKind.ImportDeclaration)
|
83
84
|
.map((node) => _angularImportsFromNode(node, source))
|
84
85
|
.reduce((acc, current) => {
|
85
86
|
for (const key of Object.keys(current)) {
|
@@ -87,7 +88,7 @@ function getDecoratorMetadata(source, identifier, module) {
|
|
87
88
|
}
|
88
89
|
return acc;
|
89
90
|
}, {});
|
90
|
-
return (0,
|
91
|
+
return (0, xplat_1.getSourceNodes)(source)
|
91
92
|
.filter((node) => {
|
92
93
|
return (node.kind == ts.SyntaxKind.Decorator &&
|
93
94
|
node.expression.kind == ts.SyntaxKind.CallExpression);
|
@@ -163,7 +164,7 @@ function addSymbolToNgModuleMetadata(source, ngModulePath, metadataField, expres
|
|
163
164
|
toInsert = `, ${metadataField}: [${expression}]`;
|
164
165
|
}
|
165
166
|
}
|
166
|
-
const newMetadataProperty = new
|
167
|
+
const newMetadataProperty = new xplat_1.InsertChange(ngModulePath, position, toInsert);
|
167
168
|
return [newMetadataProperty];
|
168
169
|
}
|
169
170
|
const assignment = matchingProperties[0];
|
@@ -230,7 +231,7 @@ function addSymbolToNgModuleMetadata(source, ngModulePath, metadataField, expres
|
|
230
231
|
toInsert = `, ${expression}`;
|
231
232
|
}
|
232
233
|
}
|
233
|
-
const insert = new
|
234
|
+
const insert = new xplat_1.InsertChange(ngModulePath, position, toInsert);
|
234
235
|
return [insert];
|
235
236
|
}
|
236
237
|
exports.addSymbolToNgModuleMetadata = addSymbolToNgModuleMetadata;
|
@@ -245,7 +246,7 @@ function removeFromNgModule(source, modulePath, property) {
|
|
245
246
|
const matchingProperty = getMatchingProperty(source, property, 'NgModule', '@angular/core');
|
246
247
|
if (matchingProperty) {
|
247
248
|
return [
|
248
|
-
new
|
249
|
+
new xplat_1.RemoveChange(modulePath, matchingProperty.getStart(source), matchingProperty.getFullText(source)),
|
249
250
|
];
|
250
251
|
}
|
251
252
|
else {
|
@@ -258,7 +259,7 @@ function addImportToModule(source, modulePath, symbolName) {
|
|
258
259
|
}
|
259
260
|
exports.addImportToModule = addImportToModule;
|
260
261
|
function addImportToTestBed(source, specPath, symbolName) {
|
261
|
-
const allCalls = ((0,
|
262
|
+
const allCalls = ((0, typescript_1.findNodes)(source, ts.SyntaxKind.CallExpression));
|
262
263
|
const configureTestingModuleObjectLiterals = allCalls
|
263
264
|
.filter((c) => c.expression.kind === ts.SyntaxKind.PropertyAccessExpression)
|
264
265
|
.filter((c) => c.expression.name.getText(source) === 'configureTestingModule')
|
@@ -270,7 +271,7 @@ function addImportToTestBed(source, specPath, symbolName) {
|
|
270
271
|
.getFirstToken(source)
|
271
272
|
.getEnd();
|
272
273
|
return [
|
273
|
-
new
|
274
|
+
new xplat_1.InsertChange(specPath, startPosition, `imports: [${symbolName}], `),
|
274
275
|
];
|
275
276
|
}
|
276
277
|
else {
|
@@ -305,10 +306,10 @@ function addRoute(ngModulePath, source, route) {
|
|
305
306
|
if (!routes)
|
306
307
|
return [];
|
307
308
|
if (routes.hasTrailingComma || routes.length === 0) {
|
308
|
-
return [new
|
309
|
+
return [new xplat_1.InsertChange(ngModulePath, routes.end, route)];
|
309
310
|
}
|
310
311
|
else {
|
311
|
-
return [new
|
312
|
+
return [new xplat_1.InsertChange(ngModulePath, routes.end, `, ${route}`)];
|
312
313
|
}
|
313
314
|
}
|
314
315
|
exports.addRoute = addRoute;
|
@@ -346,7 +347,7 @@ function addEntryComponents(source, modulePath, symbolName) {
|
|
346
347
|
}
|
347
348
|
exports.addEntryComponents = addEntryComponents;
|
348
349
|
function readBootstrapInfo(host, app) {
|
349
|
-
const config = (0,
|
350
|
+
const config = (0, xplat_1.getProjectConfig)(host, app);
|
350
351
|
let mainPath;
|
351
352
|
try {
|
352
353
|
mainPath = config.architect.build.options.main;
|
@@ -359,7 +360,7 @@ function readBootstrapInfo(host, app) {
|
|
359
360
|
}
|
360
361
|
const mainSource = host.read(mainPath).toString('utf-8');
|
361
362
|
const main = ts.createSourceFile(mainPath, mainSource, ts.ScriptTarget.Latest, true);
|
362
|
-
const moduleImports = (0,
|
363
|
+
const moduleImports = (0, xplat_1.getImport)(main, (s) => s.indexOf('.module') > -1);
|
363
364
|
if (moduleImports.length !== 1) {
|
364
365
|
throw new Error(`main.ts can only import a single module`);
|
365
366
|
}
|
package/src/utils/generator.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Tree, Rule } from '@angular-devkit/schematics';
|
2
2
|
import { XplatFeatureHelpers } from '@nstudio/xplat';
|
3
3
|
import { PlatformTypes } from '@nstudio/xplat-utils';
|
4
|
-
export
|
4
|
+
export type IGenerateType = 'component' | 'directive' | 'pipe' | 'service' | 'state';
|
5
5
|
export interface IGenerateOptions {
|
6
6
|
name: string;
|
7
7
|
feature?: string;
|
package/src/utils/generator.js
CHANGED
@@ -198,7 +198,7 @@ function getFeatureName(options) {
|
|
198
198
|
}
|
199
199
|
exports.getFeatureName = getFeatureName;
|
200
200
|
function getNxFeaturePath(tree, featureName) {
|
201
|
-
const tsConfig = (0,
|
201
|
+
const tsConfig = (0, xplat_utils_1.getJsonFromFile)(tree, 'tsconfig.base.json');
|
202
202
|
if (tsConfig) {
|
203
203
|
if (tsConfig.compilerOptions &&
|
204
204
|
tsConfig.compilerOptions.paths &&
|
@@ -589,7 +589,7 @@ function adjustSandbox(options, platform, appDirectory) {
|
|
589
589
|
homeTemplate.slice(buttonEndIndex + 9);
|
590
590
|
break;
|
591
591
|
}
|
592
|
-
(0,
|
592
|
+
(0, xplat_utils_1.updateFile)(tree, homeCmpPath, homeTemplate);
|
593
593
|
}
|
594
594
|
else {
|
595
595
|
throw new schematics_1.SchematicsException(`The --adjustSandbox option is only supported on the following at the moment: ${xplat_1.supportedSandboxPlatforms}`);
|
package/src/utils/versions.d.ts
CHANGED
@@ -5,7 +5,7 @@ export declare const angularDevkitVersion = "^15.0.0";
|
|
5
5
|
export declare const ngxTranslateVersion = "~14.0.0";
|
6
6
|
export declare const ngxTranslateHttpVersion = "~7.0.0";
|
7
7
|
export declare const coreJsVersion = "^3.6.5";
|
8
|
-
export declare const rxjsVersion = "^7.
|
9
|
-
export declare const zonejsVersion = "~0.
|
8
|
+
export declare const rxjsVersion = "^7.8.0";
|
9
|
+
export declare const zonejsVersion = "~0.13.0";
|
10
10
|
export declare const jestPresetAngular = "11.0.0";
|
11
11
|
export declare const typesJest = "29.4.0";
|
package/src/utils/versions.js
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.typesJest = exports.jestPresetAngular = exports.zonejsVersion = exports.rxjsVersion = exports.coreJsVersion = exports.ngxTranslateHttpVersion = exports.ngxTranslateVersion = exports.angularDevkitVersion = exports.angularVersion = exports.nxVersion = exports.xplatVersion = void 0;
|
4
|
-
exports.xplatVersion = '15.0.
|
4
|
+
exports.xplatVersion = '15.0.4-rc.1';
|
5
5
|
exports.nxVersion = '^15.0.0';
|
6
6
|
exports.angularVersion = '^15.0.0';
|
7
7
|
exports.angularDevkitVersion = '^15.0.0';
|
8
8
|
exports.ngxTranslateVersion = '~14.0.0';
|
9
9
|
exports.ngxTranslateHttpVersion = '~7.0.0';
|
10
10
|
exports.coreJsVersion = '^3.6.5';
|
11
|
-
exports.rxjsVersion = '^7.
|
12
|
-
exports.zonejsVersion = '~0.
|
11
|
+
exports.rxjsVersion = '^7.8.0';
|
12
|
+
exports.zonejsVersion = '~0.13.0';
|
13
13
|
exports.jestPresetAngular = '11.0.0';
|
14
14
|
exports.typesJest = '29.4.0';
|
@@ -1,116 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.config = void 0;
|
4
|
-
const workspace_1 = require("@nrwl/workspace");
|
5
|
-
const xplat_utils_1 = require("@nstudio/xplat-utils");
|
6
|
-
exports.config = {
|
7
|
-
requiresTarget: true,
|
8
|
-
additionalSupport: applitools,
|
9
|
-
logNotes: note,
|
10
|
-
};
|
11
|
-
function applitools(helperChains, options) {
|
12
|
-
return (tree, context) => {
|
13
|
-
// update support index
|
14
|
-
helperChains.push((0, workspace_1.createOrUpdate)(tree, `/apps/${options.target}-e2e/src/support/index.ts`, updateCypressIndex()));
|
15
|
-
// update plugin index
|
16
|
-
helperChains.push((0, workspace_1.createOrUpdate)(tree, `/apps/${options.target}-e2e/src/plugins/index.ts`, updateCypressPlugins()));
|
17
|
-
// ensure supportFile points to updates
|
18
|
-
const cypressConfigPath = `/apps/${options.target}-e2e/cypress.json`;
|
19
|
-
const cypressConfig = (0, xplat_utils_1.getJsonFromFile)(tree, cypressConfigPath);
|
20
|
-
// console.log('cypressConfig:', cypressConfig);
|
21
|
-
// plugin path is always defined so ensure support matches
|
22
|
-
const pluginsFilePath = cypressConfig.pluginsFile;
|
23
|
-
// console.log('pluginsFilePath:', pluginsFilePath);
|
24
|
-
const outputPath = pluginsFilePath.split('plugins/')[0];
|
25
|
-
cypressConfig.supportFile = `${outputPath}support/index.js`;
|
26
|
-
// console.log('cypressConfig.supportFile:', cypressConfig.supportFile);
|
27
|
-
helperChains.push((0, xplat_utils_1.updateJsonFile)(tree, cypressConfigPath, cypressConfig));
|
28
|
-
// Add applitools modules
|
29
|
-
const packageJson = (0, xplat_utils_1.getJsonFromFile)(tree, 'package.json');
|
30
|
-
packageJson.devDependencies = packageJson.devDependencies || {};
|
31
|
-
packageJson.devDependencies['@applitools/eyes-cypress'] = '^3.7.1';
|
32
|
-
helperChains.push((0, xplat_utils_1.updateJsonFile)(tree, 'package.json', packageJson));
|
33
|
-
// update sample test
|
34
|
-
helperChains.push((0, workspace_1.createOrUpdate)(tree, `/apps/${options.target}-e2e/src/integration/app.spec.ts`, updateSampleTest()));
|
35
|
-
};
|
36
|
-
}
|
37
|
-
function note(options) {
|
38
|
-
if (!(0, xplat_utils_1.isTesting)()) {
|
39
|
-
console.log(`Applitools support added for: ${options.target}`);
|
40
|
-
console.log(`Ensure your APPLITOOLS_API_KEY environment variable is set: https://applitools.com/tutorials/cypress.html#step-by-step-guide-run-the-demo-app`);
|
41
|
-
}
|
42
|
-
}
|
43
|
-
function updateCypressIndex() {
|
44
|
-
return `// ***********************************************************
|
45
|
-
// This example support/index.js is processed and
|
46
|
-
// loaded automatically before your test files.
|
47
|
-
//
|
48
|
-
// This is a great place to put global configuration and
|
49
|
-
// behavior that modifies Cypress.
|
50
|
-
//
|
51
|
-
// You can change the location of this file or turn off
|
52
|
-
// automatically serving support files with the
|
53
|
-
// 'supportFile' configuration option.
|
54
|
-
//
|
55
|
-
// You can read more here:
|
56
|
-
// https://on.cypress.io/configuration
|
57
|
-
// ***********************************************************
|
58
|
-
|
59
|
-
// Applitools support
|
60
|
-
import '@applitools/eyes-cypress/commands';
|
61
|
-
|
62
|
-
// Import commands.js using ES2015 syntax:
|
63
|
-
import './commands';
|
64
|
-
`;
|
65
|
-
}
|
66
|
-
function updateCypressPlugins() {
|
67
|
-
return `// ***********************************************************
|
68
|
-
// This example plugins/index.js can be used to load plugins
|
69
|
-
//
|
70
|
-
// You can change the location of this file or turn off loading
|
71
|
-
// the plugins file with the 'pluginsFile' configuration option.
|
72
|
-
//
|
73
|
-
// You can read more here:
|
74
|
-
// https://on.cypress.io/plugins-guide
|
75
|
-
// ***********************************************************
|
76
|
-
|
77
|
-
// This function is called when a project is opened or re-opened (e.g. due to
|
78
|
-
// the project's config changing)
|
79
|
-
|
80
|
-
module.exports = (on: any, config: any) => {
|
81
|
-
// 'on' is used to hook into various events Cypress emits
|
82
|
-
// 'config' is the resolved Cypress config
|
83
|
-
};
|
84
|
-
|
85
|
-
// Applitools
|
86
|
-
require('@applitools/eyes-cypress')(module);
|
87
|
-
`;
|
88
|
-
}
|
89
|
-
function updateSampleTest() {
|
90
|
-
return `import { getGreeting } from '../support/app.po';
|
91
|
-
import { eyesOpen, eyesCheckWindow, eyesClose } from '@applitools/eyes-cypress';
|
92
|
-
|
93
|
-
describe('Hello Nx', () => {
|
94
|
-
beforeEach(() => cy.visit('/'));
|
95
|
-
|
96
|
-
it('should display welcome message', () => {
|
97
|
-
|
98
|
-
// start applitools test
|
99
|
-
eyesOpen({
|
100
|
-
appName: 'myapp',
|
101
|
-
testName: 'Welcome message',
|
102
|
-
browser: { width: 800, height: 600 },
|
103
|
-
});
|
104
|
-
|
105
|
-
// check window with applitools
|
106
|
-
eyesCheckWindow('Main Page');
|
107
|
-
|
108
|
-
// standard cypress testing
|
109
|
-
getGreeting().contains('Welcome to web-myapp!');
|
110
|
-
|
111
|
-
// end applitools test
|
112
|
-
eyesClose();
|
113
|
-
});
|
114
|
-
});
|
115
|
-
`;
|
116
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;AACA,uCAAwC;AAExC,mCAA8B;AAE9B,SAAgB,kBAAkB,CAAC,OAAsB;IACvD,IAAI,CAAC,iBAAS,EAAE,EAAE;QAChB,OAAO,CAAC,GAAG,CAAC,iCAAiC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QAC/D,OAAO,CAAC,GAAG,CAAC,+IAA+I,CAAC,CAAC;KAC9J;AACH,CAAC;AALD,gDAKC"}
|
@@ -1,27 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const xplat_1 = require("@nstudio/xplat");
|
4
|
-
const xplat_utils_1 = require("@nstudio/xplat-utils");
|
5
|
-
const applitools_1 = require("./applitools");
|
6
|
-
const schematics_1 = require("@angular-devkit/schematics");
|
7
|
-
const workspace_1 = require("@nrwl/workspace");
|
8
|
-
const supportedHelpers = {
|
9
|
-
applitools: applitools_1.config,
|
10
|
-
};
|
11
|
-
function default_1(options) {
|
12
|
-
if (!options.name) {
|
13
|
-
throw new schematics_1.SchematicsException((0, xplat_1.missingArgument)('name', 'Provide the name of the helper to generate.', 'nx g @nstudio/angular:helpers applitools --target=web-myapp'));
|
14
|
-
}
|
15
|
-
const helperChain = [];
|
16
|
-
const helpers = options.name.split(',');
|
17
|
-
for (const helper of helpers) {
|
18
|
-
if (supportedHelpers[helper]) {
|
19
|
-
(0, xplat_1.buildHelperChain)(helper, options, supportedHelpers[helper], helperChain);
|
20
|
-
}
|
21
|
-
else {
|
22
|
-
helperChain.push((0, schematics_1.noop)());
|
23
|
-
}
|
24
|
-
}
|
25
|
-
return (0, schematics_1.chain)([(0, xplat_utils_1.prerun)(options), ...helperChain, (0, workspace_1.addInstallTask)()]);
|
26
|
-
}
|
27
|
-
exports.default = default_1;
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,95 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
-
});
|
10
|
-
};
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
-
const schematics_1 = require("@angular-devkit/schematics");
|
13
|
-
const xplat_utils_1 = require("@nstudio/xplat-utils");
|
14
|
-
const testing_1 = require("@nstudio/xplat/testing");
|
15
|
-
const testing_2 = require("../../utils/testing");
|
16
|
-
(0, xplat_utils_1.setTest)();
|
17
|
-
xdescribe('helpers schematic', () => {
|
18
|
-
let appTree;
|
19
|
-
beforeEach(() => {
|
20
|
-
appTree = schematics_1.Tree.empty();
|
21
|
-
appTree = (0, testing_1.createXplatWithApps)(appTree);
|
22
|
-
});
|
23
|
-
it('applitools: should create all files', () => __awaiter(void 0, void 0, void 0, function* () {
|
24
|
-
// const optionsXplat: XPlatOptions = {
|
25
|
-
// npmScope: 'testing',
|
26
|
-
// prefix: 'tt',
|
27
|
-
// platforms: 'web,nativescript'
|
28
|
-
// };
|
29
|
-
// appTree = schematicRunner.runSchematic('xplat', optionsXplat, appTree);
|
30
|
-
const appOptions = {
|
31
|
-
name: 'foo',
|
32
|
-
prefix: 'tt',
|
33
|
-
e2eTestRunner: 'cypress',
|
34
|
-
useXplat: false,
|
35
|
-
};
|
36
|
-
// console.log('appTree:', appTree);
|
37
|
-
appTree = yield (0, testing_2.runSchematic)('app', appOptions, appTree);
|
38
|
-
const cypressJsonPath = '/apps/web-foo-e2e/cypress.json';
|
39
|
-
let fileContent = (0, testing_1.getFileContent)(appTree, cypressJsonPath);
|
40
|
-
let cypressJson = (0, xplat_utils_1.jsonParse)(fileContent);
|
41
|
-
expect(cypressJson.supportFile).toBe(false);
|
42
|
-
const options = {
|
43
|
-
name: 'applitools',
|
44
|
-
target: 'web-foo',
|
45
|
-
};
|
46
|
-
// console.log('appTree:', appTree);
|
47
|
-
const tree = yield (0, testing_2.runSchematic)('helpers', options, appTree);
|
48
|
-
const files = tree.files;
|
49
|
-
// console.log(files);
|
50
|
-
expect(files.indexOf('/apps/web-foo-e2e/src/support/index.ts')).toBeGreaterThanOrEqual(0);
|
51
|
-
expect(files.indexOf('/apps/web-foo-e2e/src/plugins/index.ts')).toBeGreaterThanOrEqual(0);
|
52
|
-
// modified testing files
|
53
|
-
let filePath = '/apps/web-foo-e2e/src/support/index.ts';
|
54
|
-
fileContent = (0, testing_1.getFileContent)(tree, filePath);
|
55
|
-
// console.log(fileContent);
|
56
|
-
expect(fileContent.indexOf('@applitools/eyes-cypress/commands')).toBeGreaterThanOrEqual(0);
|
57
|
-
filePath = '/apps/web-foo-e2e/src/plugins/index.ts';
|
58
|
-
fileContent = (0, testing_1.getFileContent)(tree, filePath);
|
59
|
-
// console.log(fileContent);
|
60
|
-
expect(fileContent.indexOf(`require('@applitools/eyes-cypress')(module);`)).toBeGreaterThanOrEqual(0);
|
61
|
-
fileContent = (0, testing_1.getFileContent)(tree, cypressJsonPath);
|
62
|
-
// console.log(fileContent);
|
63
|
-
cypressJson = (0, xplat_utils_1.jsonParse)(fileContent);
|
64
|
-
expect(cypressJson.supportFile).toBe(`./src/support/index.js`);
|
65
|
-
filePath = '/apps/web-foo-e2e/src/integration/app.spec.ts';
|
66
|
-
fileContent = (0, testing_1.getFileContent)(tree, filePath);
|
67
|
-
// console.log(fileContent);
|
68
|
-
expect(fileContent.indexOf(`eyesOpen`)).toBeGreaterThanOrEqual(0);
|
69
|
-
}));
|
70
|
-
it('applitools: should throw if target is missing', () => __awaiter(void 0, void 0, void 0, function* () {
|
71
|
-
// const optionsXplat: XPlatOptions = {
|
72
|
-
// npmScope: 'testing',
|
73
|
-
// prefix: 'tt',
|
74
|
-
// platforms: 'web,nativescript'
|
75
|
-
// };
|
76
|
-
// appTree = schematicRunner.runSchematic('xplat', optionsXplat, appTree);
|
77
|
-
const appOptions = {
|
78
|
-
name: 'foo',
|
79
|
-
prefix: 'tt',
|
80
|
-
e2eTestRunner: 'cypress',
|
81
|
-
useXplat: false,
|
82
|
-
};
|
83
|
-
// console.log('appTree:', appTree);
|
84
|
-
appTree = yield (0, testing_2.runSchematic)('app', appOptions, appTree);
|
85
|
-
const cypressJsonPath = '/apps/web-foo-e2e/cypress.json';
|
86
|
-
let fileContent = (0, testing_1.getFileContent)(appTree, cypressJsonPath);
|
87
|
-
let cypressJson = (0, xplat_utils_1.jsonParse)(fileContent);
|
88
|
-
expect(cypressJson.supportFile).toBe(false);
|
89
|
-
const options = {
|
90
|
-
name: 'applitools',
|
91
|
-
};
|
92
|
-
// console.log('appTree:', appTree);
|
93
|
-
yield expect((0, testing_2.runSchematic)('helpers', options, appTree)).rejects.toThrow(`The helper "applitools" requires the --target flag.`);
|
94
|
-
}));
|
95
|
-
});
|
@@ -1,22 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"$schema": "http://json-schema.org/schema",
|
3
|
-
"$id": "xplat-angular-helpers",
|
4
|
-
"title": "xplat angular helpers",
|
5
|
-
"type": "object",
|
6
|
-
"properties": {
|
7
|
-
"name": {
|
8
|
-
"type": "string",
|
9
|
-
"description": "Comma-delimited list of helpers to generate.",
|
10
|
-
"alias": "n",
|
11
|
-
"$default": {
|
12
|
-
"$source": "argv",
|
13
|
-
"index": 0
|
14
|
-
}
|
15
|
-
},
|
16
|
-
"target": {
|
17
|
-
"type": "string",
|
18
|
-
"description": "Some helpers support targeting to generate the helper for a specific target. ie: nx g @nstudio/angular:helpers applitools --target=web-myapp"
|
19
|
-
}
|
20
|
-
},
|
21
|
-
"required": []
|
22
|
-
}
|