@nstudio/angular 15.0.4-rc.1 → 16.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 +21 -17
- package/collection.json +6 -1
- package/package.json +3 -3
- package/src/schematics/application/index.js +2 -2
- package/src/schematics/component/index.js +1 -1
- package/src/schematics/elements/index.js +10 -12
- package/src/schematics/feature/index.js +2 -2
- package/src/schematics/feature/index.spec.js +1 -1
- package/src/schematics/helpers/applitools/index.d.ts +2 -0
- package/src/schematics/helpers/applitools/index.js +115 -0
- package/src/schematics/helpers/applitools/index.js.map +1 -0
- package/src/schematics/helpers/index.d.ts +2 -0
- package/src/schematics/helpers/index.js +27 -0
- package/src/schematics/helpers/index.spec.d.ts +1 -0
- package/src/schematics/helpers/index.spec.js +95 -0
- package/src/schematics/helpers/schema.json +22 -0
- package/src/schematics/ngrx/_files/__name__.effects.spec.ts__tmpl__ +1 -1
- package/src/schematics/xplat/index.js +1 -1
- package/src/utils/ast.d.ts +75 -10
- package/src/utils/ast.js +261 -87
- package/src/utils/generator.js +58 -38
- package/src/utils/testing.js +2 -2
- package/src/utils/versions.d.ts +4 -5
- package/src/utils/versions.js +6 -7
- package/src/utils/xplat.js +7 -6
package/README.md
CHANGED
@@ -24,13 +24,19 @@
|
|
24
24
|
|
25
25
|
```
|
26
26
|
npx create-nx-workspace@latest
|
27
|
-
```
|
28
27
|
|
29
|
-
|
28
|
+
// Choose "Integrated monorepo" at the prompt:
|
30
29
|
|
31
|
-
|
30
|
+
? Choose what to create …
|
31
|
+
> Integrated monorepo: Nx configures your favorite frameworks and lets you focus on shipping features.
|
32
32
|
|
33
|
-
|
33
|
+
// Choose "apps" at the prompt:
|
34
|
+
|
35
|
+
? What to create in the new workspace …
|
36
|
+
> apps [an empty monorepo with no plugins with a layout that works best for building apps]
|
37
|
+
```
|
38
|
+
|
39
|
+
Install the tools:
|
34
40
|
|
35
41
|
```
|
36
42
|
npm i @nstudio/xplat -D
|
@@ -39,15 +45,13 @@ npm i @nstudio/xplat -D
|
|
39
45
|
You are now ready to create apps:
|
40
46
|
|
41
47
|
```
|
42
|
-
nx g app
|
48
|
+
npx nx g @nstudio/xplat:app
|
43
49
|
```
|
44
50
|
|
45
|
-
**NOTE:** If you encounter any issue, you can try creating an Nx workspace with
|
46
|
-
|
47
|
-
We have tested with the following, for example:
|
51
|
+
**NOTE:** If you encounter any issue, you can try creating an Nx workspace with version specified, for example:
|
48
52
|
|
49
53
|
```
|
50
|
-
npx create-nx-workspace@
|
54
|
+
npx create-nx-workspace@14.1.7
|
51
55
|
```
|
52
56
|
|
53
57
|
## App generation examples
|
@@ -61,7 +65,7 @@ Electron app generator can use any web app in the workspace as it's target.
|
|
61
65
|
If you don't have a web app yet, create one first:
|
62
66
|
|
63
67
|
```
|
64
|
-
nx g app sample
|
68
|
+
npx nx g @nstudio/xplat:app sample
|
65
69
|
```
|
66
70
|
|
67
71
|
> choose `web`
|
@@ -69,7 +73,7 @@ nx g app sample
|
|
69
73
|
You can now use the web app as the Electron target:
|
70
74
|
|
71
75
|
```
|
72
|
-
nx g app desktop --target=web-sample
|
76
|
+
npx nx g @nstudio/xplat:app desktop --target=web-sample
|
73
77
|
```
|
74
78
|
|
75
79
|
> choose `electron`
|
@@ -83,7 +87,7 @@ npm run start.electron.desktop
|
|
83
87
|
### Ionic
|
84
88
|
|
85
89
|
```
|
86
|
-
nx g app sample
|
90
|
+
npx nx g @nstudio/xplat:app sample
|
87
91
|
```
|
88
92
|
|
89
93
|
> choose `ionic`
|
@@ -91,13 +95,13 @@ nx g app sample
|
|
91
95
|
Develop in browser with:
|
92
96
|
|
93
97
|
```
|
94
|
-
nx serve ionic-sample
|
98
|
+
npx nx serve ionic-sample
|
95
99
|
```
|
96
100
|
|
97
101
|
Build Ionic app:
|
98
102
|
|
99
103
|
```
|
100
|
-
nx build ionic-sample
|
104
|
+
npx nx build ionic-sample
|
101
105
|
```
|
102
106
|
|
103
107
|
A. **Capacitor iOS** - Prepare for development
|
@@ -127,7 +131,7 @@ npm run open.ionic.sample.android
|
|
127
131
|
### NativeScript
|
128
132
|
|
129
133
|
```
|
130
|
-
nx g app mobile
|
134
|
+
nx g @nstudio/xplat:app mobile
|
131
135
|
```
|
132
136
|
|
133
137
|
> choose `nativescript`
|
@@ -135,13 +139,13 @@ nx g app mobile
|
|
135
139
|
A. **iOS**
|
136
140
|
|
137
141
|
```
|
138
|
-
nx run nativescript-mobile:ios
|
142
|
+
npx nx run nativescript-mobile:ios
|
139
143
|
```
|
140
144
|
|
141
145
|
B. **Android**
|
142
146
|
|
143
147
|
```
|
144
|
-
nx run nativescript-mobile:android
|
148
|
+
npx nx run nativescript-mobile:android
|
145
149
|
```
|
146
150
|
|
147
151
|
## Documentation
|
package/collection.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "nstudio/angular",
|
3
3
|
"version": "0.1",
|
4
|
-
"extends": ["@
|
4
|
+
"extends": ["@nx/angular", "@nstudio/xplat"],
|
5
5
|
"schematics": {
|
6
6
|
"ng-add": {
|
7
7
|
"factory": "./src/schematics/ng-add/ng-add",
|
@@ -54,6 +54,11 @@
|
|
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
|
+
},
|
57
62
|
"xplat": {
|
58
63
|
"factory": "./src/schematics/xplat",
|
59
64
|
"schema": "./src/schematics/xplat/schema.json",
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nstudio/angular",
|
3
|
-
"version": "
|
3
|
+
"version": "16.5.0",
|
4
4
|
"description": "Angular Plugin for xplat",
|
5
5
|
"homepage": "https://nstudio.io/xplat",
|
6
6
|
"repository": {
|
@@ -29,9 +29,9 @@
|
|
29
29
|
"migrations": "./migrations.json"
|
30
30
|
},
|
31
31
|
"dependencies": {
|
32
|
-
"@
|
32
|
+
"@nx/angular": "^16.0.0"
|
33
33
|
},
|
34
34
|
"peerDependencies": {
|
35
|
-
"@nstudio/xplat": "
|
35
|
+
"@nstudio/xplat": "16.5.0"
|
36
36
|
}
|
37
37
|
}
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
10
10
|
};
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
12
|
const schematics_1 = require("@angular-devkit/schematics");
|
13
|
-
const workspace_1 = require("@
|
13
|
+
const workspace_1 = require("@nx/workspace");
|
14
14
|
const xplat_1 = require("@nstudio/xplat");
|
15
15
|
const xplat_utils_1 = require("@nstudio/xplat-utils");
|
16
16
|
function default_1(options) {
|
@@ -53,7 +53,7 @@ function default_1(options) {
|
|
53
53
|
// interactive: false
|
54
54
|
// };
|
55
55
|
}
|
56
|
-
return (0, schematics_1.externalSchematic)('@
|
56
|
+
return (0, schematics_1.externalSchematic)('@nx/angular', 'app', nrwlWebOptions, executionOptions)(tree, context);
|
57
57
|
},
|
58
58
|
(tree, context) => addHeadlessE2e(options)(tree, context),
|
59
59
|
options.useXplat
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const schematics_1 = require("@angular-devkit/schematics");
|
4
4
|
const xplat_1 = require("@nstudio/xplat");
|
5
5
|
const xplat_utils_1 = require("@nstudio/xplat-utils");
|
6
|
-
const workspace_1 = require("@
|
6
|
+
const workspace_1 = require("@nx/workspace");
|
7
7
|
const angular_1 = require("@nstudio/angular");
|
8
8
|
let componentSettings;
|
9
9
|
function default_1(options) {
|
@@ -1,10 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const schematics_1 = require("@angular-devkit/schematics");
|
4
|
-
const workspace_1 = require("@
|
4
|
+
const workspace_1 = require("@nx/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");
|
8
7
|
let customElementList;
|
9
8
|
let componentSymbols;
|
10
9
|
let componentSymbolList;
|
@@ -171,16 +170,15 @@ function addFiles(options, extra = '') {
|
|
171
170
|
])));
|
172
171
|
}
|
173
172
|
function updateWorkspaceSupport(options, tree, context) {
|
174
|
-
const
|
175
|
-
(0,
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
});
|
173
|
+
const packagePath = 'package.json';
|
174
|
+
const json = (0, xplat_utils_1.getJsonFromFile)(tree, packagePath);
|
175
|
+
json.scripts = json.scripts || {};
|
176
|
+
json.dependencies = json.dependencies || {};
|
177
|
+
const angularVersion = json.dependencies['@angular/core'];
|
178
|
+
json.dependencies = Object.assign(Object.assign({}, json.dependencies), { '@angular/elements': angularVersion, '@webcomponents/webcomponentsjs': '^2.6.0' });
|
179
|
+
json.devDependencies = json.devDependencies || {};
|
180
|
+
json.devDependencies = Object.assign(Object.assign({}, json.devDependencies), { 'http-server': '^14.1.1', 'ngx-build-plus': '^16.0.0' });
|
181
|
+
return (0, xplat_utils_1.updateJsonFile)(tree, packagePath, json);
|
184
182
|
}
|
185
183
|
function createCustomElementList(componentSymbols) {
|
186
184
|
const customElements = ['let component;'];
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const schematics_1 = require("@angular-devkit/schematics");
|
4
|
-
const workspace_1 = require("@
|
4
|
+
const workspace_1 = require("@nx/workspace");
|
5
5
|
const xplat_1 = require("@nstudio/xplat");
|
6
6
|
const xplat_utils_1 = require("@nstudio/xplat-utils");
|
7
7
|
function default_1(options) {
|
@@ -37,7 +37,7 @@ function default_1(options) {
|
|
37
37
|
// update libs index
|
38
38
|
(tree, context) => options.onlyProject
|
39
39
|
? (0, schematics_1.noop)()(tree, context)
|
40
|
-
: xplat_1.XplatFeatureHelpers.adjustBarrelIndex(options, 'libs/xplat/features/src/lib/index.ts')
|
40
|
+
: xplat_1.XplatFeatureHelpers.adjustBarrelIndex(options, 'libs/xplat/features/src/lib/index.ts'),
|
41
41
|
// external schematic handling
|
42
42
|
(tree, context) => (0, schematics_1.chain)(externalChains),
|
43
43
|
(0, workspace_1.formatFiles)({ skipFormat: options.skipFormat }),
|
@@ -12,8 +12,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.sandboxHomeSetup = void 0;
|
13
13
|
const schematics_1 = require("@angular-devkit/schematics");
|
14
14
|
const testing_1 = require("@nstudio/xplat/testing");
|
15
|
-
const xplat_utils_1 = require("@nstudio/xplat-utils");
|
16
15
|
const testing_2 = require("../../utils/testing");
|
16
|
+
const xplat_utils_1 = require("@nstudio/xplat-utils");
|
17
17
|
describe('feature schematic', () => {
|
18
18
|
let appTree;
|
19
19
|
const defaultOptions = {
|
@@ -0,0 +1,115 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.config = void 0;
|
4
|
+
const xplat_utils_1 = require("@nstudio/xplat-utils");
|
5
|
+
exports.config = {
|
6
|
+
requiresTarget: true,
|
7
|
+
additionalSupport: applitools,
|
8
|
+
logNotes: note,
|
9
|
+
};
|
10
|
+
function applitools(helperChains, options) {
|
11
|
+
return (tree, context) => {
|
12
|
+
// update support index
|
13
|
+
helperChains.push((0, xplat_utils_1.updateFile)(tree, `/apps/${options.target}-e2e/src/support/index.ts`, updateCypressIndex()));
|
14
|
+
// update plugin index
|
15
|
+
helperChains.push((0, xplat_utils_1.updateFile)(tree, `/apps/${options.target}-e2e/src/plugins/index.ts`, updateCypressPlugins()));
|
16
|
+
// ensure supportFile points to updates
|
17
|
+
const cypressConfigPath = `/apps/${options.target}-e2e/cypress.json`;
|
18
|
+
const cypressConfig = (0, xplat_utils_1.getJsonFromFile)(tree, cypressConfigPath);
|
19
|
+
// console.log('cypressConfig:', cypressConfig);
|
20
|
+
// plugin path is always defined so ensure support matches
|
21
|
+
const pluginsFilePath = cypressConfig.pluginsFile;
|
22
|
+
// console.log('pluginsFilePath:', pluginsFilePath);
|
23
|
+
const outputPath = pluginsFilePath.split('plugins/')[0];
|
24
|
+
cypressConfig.supportFile = `${outputPath}support/index.js`;
|
25
|
+
// console.log('cypressConfig.supportFile:', cypressConfig.supportFile);
|
26
|
+
helperChains.push((0, xplat_utils_1.updateJsonFile)(tree, cypressConfigPath, cypressConfig));
|
27
|
+
// Add applitools modules
|
28
|
+
const packageJson = (0, xplat_utils_1.getJsonFromFile)(tree, 'package.json');
|
29
|
+
packageJson.devDependencies = packageJson.devDependencies || {};
|
30
|
+
packageJson.devDependencies['@applitools/eyes-cypress'] = '^3.7.1';
|
31
|
+
helperChains.push((0, xplat_utils_1.updateJsonFile)(tree, 'package.json', packageJson));
|
32
|
+
// update sample test
|
33
|
+
helperChains.push((0, xplat_utils_1.updateFile)(tree, `/apps/${options.target}-e2e/src/integration/app.spec.ts`, updateSampleTest()));
|
34
|
+
};
|
35
|
+
}
|
36
|
+
function note(options) {
|
37
|
+
if (!(0, xplat_utils_1.isTesting)()) {
|
38
|
+
console.log(`Applitools support added for: ${options.target}`);
|
39
|
+
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`);
|
40
|
+
}
|
41
|
+
}
|
42
|
+
function updateCypressIndex() {
|
43
|
+
return `// ***********************************************************
|
44
|
+
// This example support/index.js is processed and
|
45
|
+
// loaded automatically before your test files.
|
46
|
+
//
|
47
|
+
// This is a great place to put global configuration and
|
48
|
+
// behavior that modifies Cypress.
|
49
|
+
//
|
50
|
+
// You can change the location of this file or turn off
|
51
|
+
// automatically serving support files with the
|
52
|
+
// 'supportFile' configuration option.
|
53
|
+
//
|
54
|
+
// You can read more here:
|
55
|
+
// https://on.cypress.io/configuration
|
56
|
+
// ***********************************************************
|
57
|
+
|
58
|
+
// Applitools support
|
59
|
+
import '@applitools/eyes-cypress/commands';
|
60
|
+
|
61
|
+
// Import commands.js using ES2015 syntax:
|
62
|
+
import './commands';
|
63
|
+
`;
|
64
|
+
}
|
65
|
+
function updateCypressPlugins() {
|
66
|
+
return `// ***********************************************************
|
67
|
+
// This example plugins/index.js can be used to load plugins
|
68
|
+
//
|
69
|
+
// You can change the location of this file or turn off loading
|
70
|
+
// the plugins file with the 'pluginsFile' configuration option.
|
71
|
+
//
|
72
|
+
// You can read more here:
|
73
|
+
// https://on.cypress.io/plugins-guide
|
74
|
+
// ***********************************************************
|
75
|
+
|
76
|
+
// This function is called when a project is opened or re-opened (e.g. due to
|
77
|
+
// the project's config changing)
|
78
|
+
|
79
|
+
module.exports = (on: any, config: any) => {
|
80
|
+
// 'on' is used to hook into various events Cypress emits
|
81
|
+
// 'config' is the resolved Cypress config
|
82
|
+
};
|
83
|
+
|
84
|
+
// Applitools
|
85
|
+
require('@applitools/eyes-cypress')(module);
|
86
|
+
`;
|
87
|
+
}
|
88
|
+
function updateSampleTest() {
|
89
|
+
return `import { getGreeting } from '../support/app.po';
|
90
|
+
import { eyesOpen, eyesCheckWindow, eyesClose } from '@applitools/eyes-cypress';
|
91
|
+
|
92
|
+
describe('Hello Nx', () => {
|
93
|
+
beforeEach(() => cy.visit('/'));
|
94
|
+
|
95
|
+
it('should display welcome message', () => {
|
96
|
+
|
97
|
+
// start applitools test
|
98
|
+
eyesOpen({
|
99
|
+
appName: 'myapp',
|
100
|
+
testName: 'Welcome message',
|
101
|
+
browser: { width: 800, height: 600 },
|
102
|
+
});
|
103
|
+
|
104
|
+
// check window with applitools
|
105
|
+
eyesCheckWindow('Main Page');
|
106
|
+
|
107
|
+
// standard cypress testing
|
108
|
+
getGreeting().contains('Welcome to web-myapp!');
|
109
|
+
|
110
|
+
// end applitools test
|
111
|
+
eyesClose();
|
112
|
+
});
|
113
|
+
});
|
114
|
+
`;
|
115
|
+
}
|
@@ -0,0 +1 @@
|
|
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"}
|
@@ -0,0 +1,27 @@
|
|
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("@nx/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;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,95 @@
|
|
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
|
+
});
|
@@ -0,0 +1,22 @@
|
|
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
|
+
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { TestBed } from '@angular/core/testing';
|
2
2
|
import { provideMockStore } from '@ngrx/store/testing';
|
3
3
|
import { provideMockActions } from '@ngrx/effects/testing';
|
4
|
-
import { hot } from '@
|
4
|
+
import { hot } from '@nx/angular/testing';
|
5
5
|
|
6
6
|
import { <%= utils.classify(name) %>Effects } from './<%= name %>.effects';
|
7
7
|
import { <%= utils.classify(name) %>Actions } from './<%= name %>.actions';
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const schematics_1 = require("@angular-devkit/schematics");
|
4
|
-
const workspace_1 = require("@
|
4
|
+
const workspace_1 = require("@nx/workspace");
|
5
5
|
const xplat_1 = require("@nstudio/xplat");
|
6
6
|
const xplat_utils_1 = require("@nstudio/xplat-utils");
|
7
7
|
const xplat_2 = require("../../utils/xplat");
|
package/src/utils/ast.d.ts
CHANGED
@@ -1,15 +1,78 @@
|
|
1
1
|
import * as ts from 'typescript';
|
2
|
-
import { Tree } from '@
|
3
|
-
|
4
|
-
export declare function
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
import { Tree } from '@nx/devkit';
|
3
|
+
type DecoratorName = 'Component' | 'Directive' | 'NgModule' | 'Pipe';
|
4
|
+
export declare function addToCollection(tree: Tree, source: ts.SourceFile, barrelIndexPath: string, symbolName: string, insertSpaces?: string): ts.SourceFile;
|
5
|
+
/**
|
6
|
+
* Check if the Component, Directive or Pipe is standalone
|
7
|
+
* @param sourceFile TS Source File containing the token to check
|
8
|
+
* @param decoratorName The type of decorator to check (Component, Directive, Pipe)
|
9
|
+
*/
|
10
|
+
export declare function isStandalone(sourceFile: ts.SourceFile, decoratorName: DecoratorName): boolean;
|
11
|
+
export declare function getDecoratorMetadata(source: ts.SourceFile, identifier: string, module: string): ts.Node[];
|
12
|
+
export declare function _addSymbolToNgModuleMetadata(host: Tree, source: ts.SourceFile, ngModulePath: string, metadataField: string, expression: string): ts.SourceFile;
|
13
|
+
export declare function removeFromNgModule(host: Tree, source: ts.SourceFile, modulePath: string, property: string): ts.SourceFile;
|
14
|
+
/**
|
15
|
+
* Add an import to a Standalone Component
|
16
|
+
* @param host Virtual Tree
|
17
|
+
* @param source TS Source File containing the Component
|
18
|
+
* @param componentPath The path to the Component
|
19
|
+
* @param symbolName The import to add to the Component
|
20
|
+
*/
|
21
|
+
export declare function addImportToComponent(host: Tree, source: ts.SourceFile, componentPath: string, symbolName: string): ts.SourceFile;
|
22
|
+
/**
|
23
|
+
* Add an import to a Standalone Directive
|
24
|
+
* @param host Virtual Tree
|
25
|
+
* @param source TS Source File containing the Directive
|
26
|
+
* @param directivePath The path to the Directive
|
27
|
+
* @param symbolName The import to add to the Directive
|
28
|
+
*/
|
29
|
+
export declare function addImportToDirective(host: Tree, source: ts.SourceFile, directivePath: string, symbolName: string): ts.SourceFile;
|
30
|
+
/**
|
31
|
+
* Add an import to a Standalone Pipe
|
32
|
+
* @param host Virtual Tree
|
33
|
+
* @param source TS Source File containing the Pipe
|
34
|
+
* @param pipePath The path to the Pipe
|
35
|
+
* @param symbolName The import to add to the Pipe
|
36
|
+
*/
|
37
|
+
export declare function addImportToPipe(host: Tree, source: ts.SourceFile, pipePath: string, symbolName: string): ts.SourceFile;
|
38
|
+
/**
|
39
|
+
* Add an import to an NgModule
|
40
|
+
* @param host Virtual Tree
|
41
|
+
* @param source TS Source File containing the NgModule
|
42
|
+
* @param modulePath The path to the NgModule
|
43
|
+
* @param symbolName The import to add to the NgModule
|
44
|
+
*/
|
45
|
+
export declare function addImportToModule(host: Tree, source: ts.SourceFile, modulePath: string, symbolName: string): ts.SourceFile;
|
46
|
+
export declare function addImportToTestBed(host: Tree, source: ts.SourceFile, specPath: string, symbolName: string): ts.SourceFile;
|
47
|
+
export declare function addDeclarationsToTestBed(host: Tree, source: ts.SourceFile, specPath: string, symbolName: string[]): ts.SourceFile;
|
48
|
+
export declare function replaceIntoToTestBed(host: Tree, source: ts.SourceFile, specPath: string, newSymbol: string, previousSymbol: string): ts.SourceFile;
|
8
49
|
export declare function getBootstrapComponent(source: ts.SourceFile, moduleClassName: string): string;
|
9
|
-
export declare function
|
10
|
-
|
11
|
-
|
12
|
-
|
50
|
+
export declare function addRouteToNgModule(host: Tree, ngModulePath: string, source: ts.SourceFile, route: string): ts.SourceFile;
|
51
|
+
/**
|
52
|
+
* Add a provider to bootstrapApplication call for Standalone Applications
|
53
|
+
* @param tree Virtual Tree
|
54
|
+
* @param filePath Path to the file containing the bootstrapApplication call
|
55
|
+
* @param providerToAdd Provider to add
|
56
|
+
*/
|
57
|
+
export declare function addProviderToBootstrapApplication(tree: Tree, filePath: string, providerToAdd: string): void;
|
58
|
+
/**
|
59
|
+
* Add a provider to an NgModule
|
60
|
+
* @param host Virtual Tree
|
61
|
+
* @param source TS Source File containing the NgModule
|
62
|
+
* @param modulePath Path to the NgModule
|
63
|
+
* @param symbolName The provider to add
|
64
|
+
*/
|
65
|
+
export declare function addProviderToModule(host: Tree, source: ts.SourceFile, modulePath: string, symbolName: string): ts.SourceFile;
|
66
|
+
/**
|
67
|
+
* Add a provider to a Standalone Component
|
68
|
+
* @param host Virtual Tree
|
69
|
+
* @param source TS Source File containing the Component
|
70
|
+
* @param componentPath Path to the Component
|
71
|
+
* @param symbolName The provider to add
|
72
|
+
*/
|
73
|
+
export declare function addProviderToComponent(host: Tree, source: ts.SourceFile, componentPath: string, symbolName: string): ts.SourceFile;
|
74
|
+
export declare function addDeclarationToModule(host: Tree, source: ts.SourceFile, modulePath: string, symbolName: string): ts.SourceFile;
|
75
|
+
export declare function addEntryComponents(host: Tree, source: ts.SourceFile, modulePath: string, symbolName: string): ts.SourceFile;
|
13
76
|
export declare function readBootstrapInfo(host: Tree, app: string): {
|
14
77
|
moduleSpec: string;
|
15
78
|
modulePath: string;
|
@@ -20,3 +83,5 @@ export declare function readBootstrapInfo(host: Tree, app: string): {
|
|
20
83
|
bootstrapComponentFileName: string;
|
21
84
|
};
|
22
85
|
export declare function getDecoratorPropertyValueNode(host: Tree, modulePath: string, identifier: string, property: string, module: string): ts.Node;
|
86
|
+
export declare function getTsSourceFile(host: Tree, path: string): ts.SourceFile;
|
87
|
+
export {};
|