@dugararchit/cdk 0.0.0-dugararchit
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/_index.scss +8 -0
- package/a11y/_index.import.scss +2 -0
- package/a11y/_index.scss +102 -0
- package/a11y/a11y-prebuilt.scss +3 -0
- package/fesm2022/stagefright5-cdk-a11y.mjs +2381 -0
- package/fesm2022/stagefright5-cdk-a11y.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-accordion.mjs +267 -0
- package/fesm2022/stagefright5-cdk-accordion.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-bidi.mjs +185 -0
- package/fesm2022/stagefright5-cdk-bidi.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-clipboard.mjs +250 -0
- package/fesm2022/stagefright5-cdk-clipboard.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-coercion.mjs +128 -0
- package/fesm2022/stagefright5-cdk-coercion.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-collections.mjs +472 -0
- package/fesm2022/stagefright5-cdk-collections.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-drag-drop.mjs +3690 -0
- package/fesm2022/stagefright5-cdk-drag-drop.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-keycodes.mjs +159 -0
- package/fesm2022/stagefright5-cdk-keycodes.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-layout.mjs +246 -0
- package/fesm2022/stagefright5-cdk-layout.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-observers.mjs +203 -0
- package/fesm2022/stagefright5-cdk-observers.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-overlay.mjs +3033 -0
- package/fesm2022/stagefright5-cdk-overlay.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-platform.mjs +375 -0
- package/fesm2022/stagefright5-cdk-platform.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-portal.mjs +672 -0
- package/fesm2022/stagefright5-cdk-portal.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-scrolling.mjs +1399 -0
- package/fesm2022/stagefright5-cdk-scrolling.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-stepper.mjs +624 -0
- package/fesm2022/stagefright5-cdk-stepper.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-table.mjs +2346 -0
- package/fesm2022/stagefright5-cdk-table.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-testing-protractor.mjs +324 -0
- package/fesm2022/stagefright5-cdk-testing-protractor.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-testing-selenium-webdriver.mjs +364 -0
- package/fesm2022/stagefright5-cdk-testing-selenium-webdriver.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-testing-testbed.mjs +806 -0
- package/fesm2022/stagefright5-cdk-testing-testbed.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-testing.mjs +740 -0
- package/fesm2022/stagefright5-cdk-testing.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-text-field.mjs +453 -0
- package/fesm2022/stagefright5-cdk-text-field.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-tree.mjs +945 -0
- package/fesm2022/stagefright5-cdk-tree.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk.mjs +26 -0
- package/fesm2022/stagefright5-cdk.mjs.map +1 -0
- package/overlay/_index-deprecated.scss +13 -0
- package/overlay/_index.import.scss +13 -0
- package/overlay/_index.scss +148 -0
- package/overlay/overlay-prebuilt.scss +3 -0
- package/package.json +159 -0
- package/schematics/ng-update/test-cases/misc/global-stylesheets-test.scss +3 -0
- package/schematics/schematics/BUILD.bazel +104 -0
- package/schematics/schematics/README.md +4 -0
- package/schematics/schematics/collection.json +18 -0
- package/schematics/schematics/index.ts +22 -0
- package/schematics/schematics/migration.json +50 -0
- package/schematics/schematics/ng-add/index.spec.ts +50 -0
- package/schematics/schematics/ng-add/index.ts +39 -0
- package/schematics/schematics/ng-add/package-config.ts +62 -0
- package/schematics/schematics/ng-add/schema.json +16 -0
- package/schematics/schematics/ng-add/schema.ts +12 -0
- package/schematics/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.__style__.template +53 -0
- package/schematics/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html.template +17 -0
- package/schematics/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.spec.ts.template +29 -0
- package/schematics/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.ts.template +43 -0
- package/schematics/schematics/ng-generate/drag-drop/index.spec.ts +205 -0
- package/schematics/schematics/ng-generate/drag-drop/index.ts +35 -0
- package/schematics/schematics/ng-generate/drag-drop/schema.json +93 -0
- package/schematics/schematics/ng-generate/drag-drop/schema.ts +11 -0
- package/schematics/schematics/ng-update/data/attribute-selectors.ts +29 -0
- package/schematics/schematics/ng-update/data/class-names.ts +50 -0
- package/schematics/schematics/ng-update/data/constructor-checks.ts +75 -0
- package/schematics/schematics/ng-update/data/css-selectors.ts +33 -0
- package/schematics/schematics/ng-update/data/element-selectors.ts +21 -0
- package/schematics/schematics/ng-update/data/index.ts +18 -0
- package/schematics/schematics/ng-update/data/input-names.ts +118 -0
- package/schematics/schematics/ng-update/data/method-call-checks.ts +63 -0
- package/schematics/schematics/ng-update/data/output-names.ts +42 -0
- package/schematics/schematics/ng-update/data/property-names.ts +151 -0
- package/schematics/schematics/ng-update/data/symbol-removal.ts +22 -0
- package/schematics/schematics/ng-update/devkit-file-system.ts +87 -0
- package/schematics/schematics/ng-update/devkit-migration-rule.ts +185 -0
- package/schematics/schematics/ng-update/devkit-migration.ts +47 -0
- package/schematics/schematics/ng-update/find-stylesheets.ts +43 -0
- package/schematics/schematics/ng-update/html-parsing/angular.ts +49 -0
- package/schematics/schematics/ng-update/html-parsing/elements.ts +66 -0
- package/schematics/schematics/ng-update/index.ts +113 -0
- package/schematics/schematics/ng-update/migrations/attribute-selectors.ts +83 -0
- package/schematics/schematics/ng-update/migrations/class-inheritance.ts +63 -0
- package/schematics/schematics/ng-update/migrations/class-names.ts +107 -0
- package/schematics/schematics/ng-update/migrations/constructor-signature.ts +170 -0
- package/schematics/schematics/ng-update/migrations/css-selectors.ts +83 -0
- package/schematics/schematics/ng-update/migrations/element-selectors.ts +75 -0
- package/schematics/schematics/ng-update/migrations/input-names.ts +83 -0
- package/schematics/schematics/ng-update/migrations/method-call-arguments.ts +70 -0
- package/schematics/schematics/ng-update/migrations/misc-template.ts +36 -0
- package/schematics/schematics/ng-update/migrations/output-names.ts +61 -0
- package/schematics/schematics/ng-update/migrations/property-names.ts +61 -0
- package/schematics/schematics/ng-update/migrations/symbol-removal.ts +51 -0
- package/schematics/schematics/ng-update/migrations/tilde-import-v13/tilde-import-migration.ts +40 -0
- package/schematics/schematics/ng-update/public-api.ts +18 -0
- package/schematics/schematics/ng-update/test-cases/index.spec.ts +18 -0
- package/schematics/schematics/ng-update/test-cases/misc/external-resource-resolution.spec.ts +32 -0
- package/schematics/schematics/ng-update/test-cases/misc/external-resource-resolution_input.ts +22 -0
- package/schematics/schematics/ng-update/test-cases/misc/global-stylesheets-test.scss +3 -0
- package/schematics/schematics/ng-update/test-cases/misc/global-stylesheets.spec.ts +50 -0
- package/schematics/schematics/ng-update/test-cases/misc/global-stylesheets_input.ts +8 -0
- package/schematics/schematics/ng-update/test-cases/misc/method-call-checks.spec.ts +20 -0
- package/schematics/schematics/ng-update/test-cases/misc/method-call-checks_input.ts +18 -0
- package/schematics/schematics/ng-update/test-cases/misc/module-resolution.spec.ts +27 -0
- package/schematics/schematics/ng-update/test-cases/v13/misc/tilde-import-v13.spec.ts +149 -0
- package/schematics/schematics/ng-update/test-cases/v6/attribute-selectors_expected_output.ts +36 -0
- package/schematics/schematics/ng-update/test-cases/v6/attribute-selectors_input.ts +36 -0
- package/schematics/schematics/ng-update/test-cases/v6/class-names_expected_output.ts +8 -0
- package/schematics/schematics/ng-update/test-cases/v6/class-names_input.ts +8 -0
- package/schematics/schematics/ng-update/test-cases/v6/input-names_expected_output.ts +22 -0
- package/schematics/schematics/ng-update/test-cases/v6/input-names_input.ts +22 -0
- package/schematics/schematics/ng-update/test-cases/v6/property-names_expected_output.ts +64 -0
- package/schematics/schematics/ng-update/test-cases/v6/property-names_input.ts +64 -0
- package/schematics/schematics/ng-update/test-cases/v7/property-names_expected_output.ts +28 -0
- package/schematics/schematics/ng-update/test-cases/v7/property-names_input.ts +28 -0
- package/schematics/schematics/ng-update/typescript/base-types.ts +22 -0
- package/schematics/schematics/ng-update/typescript/imports.ts +54 -0
- package/schematics/schematics/ng-update/typescript/literal.ts +32 -0
- package/schematics/schematics/ng-update/typescript/module-specifiers.ts +39 -0
- package/schematics/schematics/ng-update/update-schematic.md +209 -0
- package/schematics/schematics/ng-update/upgrade-data.ts +79 -0
- package/schematics/schematics/paths.ts +15 -0
- package/schematics/schematics/testing/BUILD.bazel +27 -0
- package/schematics/schematics/testing/file-content.ts +20 -0
- package/schematics/schematics/testing/index.ts +14 -0
- package/schematics/schematics/testing/post-scheduled-tasks.ts +45 -0
- package/schematics/schematics/testing/resolve-bazel-path.ts +46 -0
- package/schematics/schematics/testing/test-app.ts +21 -0
- package/schematics/schematics/testing/test-case-setup.ts +236 -0
- package/schematics/schematics/testing/test-library.ts +21 -0
- package/schematics/schematics/testing/test-project.ts +40 -0
- package/schematics/schematics/testing/tsconfig.json +7 -0
- package/schematics/schematics/tsconfig.json +28 -0
- package/schematics/schematics/update-tool/BUILD.bazel +19 -0
- package/schematics/schematics/update-tool/component-resource-collector.ts +195 -0
- package/schematics/schematics/update-tool/file-system.ts +78 -0
- package/schematics/schematics/update-tool/index.ts +191 -0
- package/schematics/schematics/update-tool/logger.ts +23 -0
- package/schematics/schematics/update-tool/migration.ts +88 -0
- package/schematics/schematics/update-tool/public-api.ts +16 -0
- package/schematics/schematics/update-tool/target-version.ts +31 -0
- package/schematics/schematics/update-tool/tsconfig.json +7 -0
- package/schematics/schematics/update-tool/update-recorder.ts +14 -0
- package/schematics/schematics/update-tool/utils/decorators.ts +54 -0
- package/schematics/schematics/update-tool/utils/functions.ts +18 -0
- package/schematics/schematics/update-tool/utils/imports.ts +128 -0
- package/schematics/schematics/update-tool/utils/line-mappings.ts +84 -0
- package/schematics/schematics/update-tool/utils/parse-tsconfig.ts +25 -0
- package/schematics/schematics/update-tool/utils/property-name.ts +28 -0
- package/schematics/schematics/update-tool/utils/virtual-host.ts +116 -0
- package/schematics/schematics/update-tool/version-changes.ts +49 -0
- package/schematics/schematics/utils/ast/ng-module-imports.spec.ts +43 -0
- package/schematics/schematics/utils/ast/ng-module-imports.ts +102 -0
- package/schematics/schematics/utils/ast.ts +88 -0
- package/schematics/schematics/utils/build-component.ts +252 -0
- package/schematics/schematics/utils/get-project.ts +27 -0
- package/schematics/schematics/utils/html-manipulation.ts +105 -0
- package/schematics/schematics/utils/index.ts +19 -0
- package/schematics/schematics/utils/parse5-element.ts +34 -0
- package/schematics/schematics/utils/project-index-file.ts +21 -0
- package/schematics/schematics/utils/project-main-file.ts +26 -0
- package/schematics/schematics/utils/project-style-file.ts +53 -0
- package/schematics/schematics/utils/project-targets.ts +43 -0
- package/schematics/schematics/utils/project-tsconfig-paths.spec.ts +91 -0
- package/schematics/schematics/utils/project-tsconfig-paths.ts +49 -0
- package/schematics/schematics/utils/schematic-options.ts +65 -0
- package/schematics/schematics/utils/vendored-ast-utils/index.ts +599 -0
- package/scrolling/virtual-scroll-viewport.scss +87 -0
- package/table/table.scss +3 -0
- package/text-field/_index.import.scss +2 -0
- package/text-field/_index.scss +89 -0
- package/text-field/text-field-prebuilt.scss +4 -0
- package/types/stagefright5-cdk-a11y.d.ts +1160 -0
- package/types/stagefright5-cdk-accordion.d.ts +95 -0
- package/types/stagefright5-cdk-bidi.d.ts +95 -0
- package/types/stagefright5-cdk-clipboard.d.ts +116 -0
- package/types/stagefright5-cdk-coercion.d.ts +101 -0
- package/types/stagefright5-cdk-collections.d.ts +405 -0
- package/types/stagefright5-cdk-drag-drop.d.ts +1471 -0
- package/types/stagefright5-cdk-keycodes.d.ts +142 -0
- package/types/stagefright5-cdk-layout.d.ts +96 -0
- package/types/stagefright5-cdk-observers.d.ts +91 -0
- package/types/stagefright5-cdk-overlay.d.ts +1258 -0
- package/types/stagefright5-cdk-platform.d.ts +130 -0
- package/types/stagefright5-cdk-portal.d.ts +327 -0
- package/types/stagefright5-cdk-scrolling.d.ts +631 -0
- package/types/stagefright5-cdk-stepper.d.ts +302 -0
- package/types/stagefright5-cdk-table.d.ts +1128 -0
- package/types/stagefright5-cdk-testing-protractor.d.ts +146 -0
- package/types/stagefright5-cdk-testing-selenium-webdriver.d.ts +161 -0
- package/types/stagefright5-cdk-testing-testbed.d.ts +168 -0
- package/types/stagefright5-cdk-testing.d.ts +735 -0
- package/types/stagefright5-cdk-text-field.d.ts +171 -0
- package/types/stagefright5-cdk-tree.d.ts +522 -0
- package/types/stagefright5-cdk.d.ts +14 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "./node_modules/@angular-devkit/schematics/collection-schema.json",
|
|
3
|
+
"schematics": {
|
|
4
|
+
"ng-add": {
|
|
5
|
+
"description": "Installs the Angular CDK",
|
|
6
|
+
"factory": "./ng-add/index",
|
|
7
|
+
"schema": "./ng-add/schema.json",
|
|
8
|
+
"aliases": ["install"],
|
|
9
|
+
"hidden": true
|
|
10
|
+
},
|
|
11
|
+
"drag-drop": {
|
|
12
|
+
"description": "Generates a component using the Drag and Drop module",
|
|
13
|
+
"factory": "./ng-generate/drag-drop/index",
|
|
14
|
+
"schema": "./ng-generate/drag-drop/schema.json",
|
|
15
|
+
"aliases": ["dragdrop", "drag-and-drop"]
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export * from './utils';
|
|
10
|
+
export * from './ng-update/public-api';
|
|
11
|
+
export * from './update-tool/public-api';
|
|
12
|
+
|
|
13
|
+
// Re-exported so that Angular Material schematic code can consume the
|
|
14
|
+
// vendored "@schematics/angular" AST utils.
|
|
15
|
+
export * from './utils/vendored-ast-utils';
|
|
16
|
+
|
|
17
|
+
// Re-export parse5 from the CDK. Material schematics code cannot simply import
|
|
18
|
+
// "parse5" because it could result in a different version. As long as we import
|
|
19
|
+
// it from within the CDK, it will always be the correct version that is specified
|
|
20
|
+
// in the CDK "package.json" as optional dependency.
|
|
21
|
+
import * as parse5 from 'parse5';
|
|
22
|
+
export {parse5};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "./node_modules/@angular-devkit/schematics/collection-schema.json",
|
|
3
|
+
"schematics": {
|
|
4
|
+
"migration-v6": {
|
|
5
|
+
"version": "6.0.0",
|
|
6
|
+
"description": "Updates the Angular CDK to v6",
|
|
7
|
+
"factory": "./ng-update/index#updateToV6"
|
|
8
|
+
},
|
|
9
|
+
"migration-v7": {
|
|
10
|
+
"version": "7.0.0",
|
|
11
|
+
"description": "Updates the Angular CDK to v7",
|
|
12
|
+
"factory": "./ng-update/index#updateToV7"
|
|
13
|
+
},
|
|
14
|
+
"migration-v8": {
|
|
15
|
+
"version": "8.0.0",
|
|
16
|
+
"description": "Updates the Angular CDK to v8",
|
|
17
|
+
"factory": "./ng-update/index#updateToV8"
|
|
18
|
+
},
|
|
19
|
+
"migration-v9": {
|
|
20
|
+
"version": "9.0.0-0",
|
|
21
|
+
"description": "Updates the Angular CDK to v9",
|
|
22
|
+
"factory": "./ng-update/index#updateToV9"
|
|
23
|
+
},
|
|
24
|
+
"migration-v10": {
|
|
25
|
+
"version": "10.0.0-0",
|
|
26
|
+
"description": "Updates the Angular CDK to v10",
|
|
27
|
+
"factory": "./ng-update/index#updateToV10"
|
|
28
|
+
},
|
|
29
|
+
"migration-v11": {
|
|
30
|
+
"version": "11.0.0-0",
|
|
31
|
+
"description": "Updates the Angular CDK to v11",
|
|
32
|
+
"factory": "./ng-update/index#updateToV11"
|
|
33
|
+
},
|
|
34
|
+
"migration-v12": {
|
|
35
|
+
"version": "12.0.0-0",
|
|
36
|
+
"description": "Updates the Angular CDK to v12",
|
|
37
|
+
"factory": "./ng-update/index#updateToV12"
|
|
38
|
+
},
|
|
39
|
+
"migration-v13": {
|
|
40
|
+
"version": "13.0.0-0",
|
|
41
|
+
"description": "Updates the Angular CDK to v13",
|
|
42
|
+
"factory": "./ng-update/index#updateToV13"
|
|
43
|
+
},
|
|
44
|
+
"ng-post-update": {
|
|
45
|
+
"description": "Prints out results after ng-update.",
|
|
46
|
+
"factory": "./ng-update/index#postUpdate",
|
|
47
|
+
"private": true
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {Tree} from '@angular-devkit/schematics';
|
|
2
|
+
import {SchematicTestRunner} from '@angular-devkit/schematics/testing';
|
|
3
|
+
import {COLLECTION_PATH} from '../paths';
|
|
4
|
+
import {createTestApp, getFileContent} from '../testing';
|
|
5
|
+
import {addPackageToPackageJson} from './package-config';
|
|
6
|
+
|
|
7
|
+
interface PackageJson {
|
|
8
|
+
dependencies: Record<string, string>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
describe('CDK ng-add', () => {
|
|
12
|
+
let runner: SchematicTestRunner;
|
|
13
|
+
let appTree: Tree;
|
|
14
|
+
|
|
15
|
+
beforeEach(async () => {
|
|
16
|
+
runner = new SchematicTestRunner('schematics', COLLECTION_PATH);
|
|
17
|
+
appTree = await createTestApp(runner);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should update the package.json', async () => {
|
|
21
|
+
const tree = await runner.runSchematicAsync('ng-add', {}, appTree).toPromise();
|
|
22
|
+
const packageJson = JSON.parse(getFileContent(tree, '/package.json')) as PackageJson;
|
|
23
|
+
const dependencies = packageJson.dependencies;
|
|
24
|
+
|
|
25
|
+
expect(dependencies['@dugararchit/cdk']).toBe('~0.0.0-dugararchit');
|
|
26
|
+
expect(Object.keys(dependencies))
|
|
27
|
+
.withContext('Expected the modified "dependencies" to be sorted alphabetically.')
|
|
28
|
+
.toEqual(Object.keys(dependencies).sort());
|
|
29
|
+
expect(runner.tasks.some(task => task.name === 'node-package'))
|
|
30
|
+
.withContext('Expected the package manager to be scheduled in order to update lock files.')
|
|
31
|
+
.toBe(true);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('should respect version range from CLI ng-add command', async () => {
|
|
35
|
+
// Simulates the behavior of the CLI `ng add` command. The command inserts the
|
|
36
|
+
// requested package version into the `package.json` before the actual schematic runs.
|
|
37
|
+
addPackageToPackageJson(appTree, '@dugararchit/cdk', '^9.0.0');
|
|
38
|
+
|
|
39
|
+
const tree = await runner.runSchematicAsync('ng-add', {}, appTree).toPromise();
|
|
40
|
+
const packageJson = JSON.parse(getFileContent(tree, '/package.json')) as PackageJson;
|
|
41
|
+
const dependencies = packageJson.dependencies;
|
|
42
|
+
|
|
43
|
+
expect(dependencies['@dugararchit/cdk']).toBe('^9.0.0');
|
|
44
|
+
expect(runner.tasks.some(task => task.name === 'node-package'))
|
|
45
|
+
.withContext(
|
|
46
|
+
'Expected the package manager to not run since the CDK version ' + 'was already inserted.',
|
|
47
|
+
)
|
|
48
|
+
.toBe(false);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {Rule, SchematicContext, Tree} from '@angular-devkit/schematics';
|
|
10
|
+
import {NodePackageInstallTask} from '@angular-devkit/schematics/tasks';
|
|
11
|
+
import {addPackageToPackageJson, getPackageVersionFromPackageJson} from './package-config';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Schematic factory entry-point for the `ng-add` schematic. The ng-add schematic will be
|
|
15
|
+
* automatically executed if developers run `ng add @dugararchit/cdk`.
|
|
16
|
+
*
|
|
17
|
+
* By default, the CLI already installs the package that has been specified with `ng add`.
|
|
18
|
+
* We just store the version in the `package.json` in case the package manager didn't. Also
|
|
19
|
+
* this ensures that there will be no error that says that the CDK does not support `ng add`.
|
|
20
|
+
*/
|
|
21
|
+
export default function (): Rule {
|
|
22
|
+
return (host: Tree, context: SchematicContext) => {
|
|
23
|
+
// The CLI inserts `@dugararchit/cdk` into the `package.json` before this schematic runs. This
|
|
24
|
+
// means that we do not need to insert the CDK into `package.json` files again. In some cases
|
|
25
|
+
// though, it could happen that this schematic runs outside of the CLI `ng add` command, or
|
|
26
|
+
// the CDK is only listed as a dev dependency. If that is the case, we insert a version based
|
|
27
|
+
// on the current build version (substituted version placeholder).
|
|
28
|
+
if (getPackageVersionFromPackageJson(host, '@dugararchit/cdk') === null) {
|
|
29
|
+
// In order to align the CDK version with other Angular dependencies that are setup by
|
|
30
|
+
// `@schematics/angular`, we use tilde instead of caret. This is default for Angular
|
|
31
|
+
// dependencies in new CLI projects.
|
|
32
|
+
addPackageToPackageJson(host, '@dugararchit/cdk', `~0.0.0-dugararchit`);
|
|
33
|
+
|
|
34
|
+
// Add a task to run the package manager. This is necessary because we updated the
|
|
35
|
+
// workspace "package.json" file and we want lock files to reflect the new version range.
|
|
36
|
+
context.addTask(new NodePackageInstallTask());
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {Tree} from '@angular-devkit/schematics';
|
|
10
|
+
|
|
11
|
+
interface PackageJson {
|
|
12
|
+
dependencies: Record<string, string>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Sorts the keys of the given object.
|
|
17
|
+
* @returns A new object instance with sorted keys
|
|
18
|
+
*/
|
|
19
|
+
function sortObjectByKeys(obj: Record<string, string>) {
|
|
20
|
+
return Object.keys(obj)
|
|
21
|
+
.sort()
|
|
22
|
+
.reduce((result, key) => {
|
|
23
|
+
result[key] = obj[key];
|
|
24
|
+
return result;
|
|
25
|
+
}, {} as Record<string, string>);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Adds a package to the package.json in the given host tree. */
|
|
29
|
+
export function addPackageToPackageJson(host: Tree, pkg: string, version: string): Tree {
|
|
30
|
+
if (host.exists('package.json')) {
|
|
31
|
+
const sourceText = host.read('package.json')!.toString('utf-8');
|
|
32
|
+
const json = JSON.parse(sourceText) as PackageJson;
|
|
33
|
+
|
|
34
|
+
if (!json.dependencies) {
|
|
35
|
+
json.dependencies = {};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (!json.dependencies[pkg]) {
|
|
39
|
+
json.dependencies[pkg] = version;
|
|
40
|
+
json.dependencies = sortObjectByKeys(json.dependencies);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
host.overwrite('package.json', JSON.stringify(json, null, 2));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return host;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Gets the version of the specified package by looking at the package.json in the given tree. */
|
|
50
|
+
export function getPackageVersionFromPackageJson(tree: Tree, name: string): string | null {
|
|
51
|
+
if (!tree.exists('package.json')) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const packageJson = JSON.parse(tree.read('package.json')!.toString('utf8')) as PackageJson;
|
|
56
|
+
|
|
57
|
+
if (packageJson.dependencies && packageJson.dependencies[name]) {
|
|
58
|
+
return packageJson.dependencies[name];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"$id": "angular-cdk-ng-add",
|
|
4
|
+
"title": "Angular CDK ng-add",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"project": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "The name of the project.",
|
|
10
|
+
"$default": {
|
|
11
|
+
"$source": "projectName"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"required": []
|
|
16
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export interface Schema {
|
|
10
|
+
/** Name of the project to target. */
|
|
11
|
+
project: string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
width: 400px;
|
|
3
|
+
max-width: 100%;
|
|
4
|
+
margin: 0 20px;
|
|
5
|
+
display: inline-block;
|
|
6
|
+
vertical-align: top;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.list {
|
|
10
|
+
border: solid 1px #ccc;
|
|
11
|
+
min-height: 60px;
|
|
12
|
+
background: white;
|
|
13
|
+
border-radius: 4px;
|
|
14
|
+
display: block;
|
|
15
|
+
overflow: hidden;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.list-item {
|
|
19
|
+
padding: 20px 10px;
|
|
20
|
+
border-bottom: solid 1px #ccc;
|
|
21
|
+
box-sizing: border-box;
|
|
22
|
+
cursor: move;
|
|
23
|
+
background: white;
|
|
24
|
+
color: black;
|
|
25
|
+
font-size: 14px;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.list-item:last-child {
|
|
29
|
+
border: none;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* Highlight the list item that is being dragged. */
|
|
33
|
+
.cdk-drag-preview {
|
|
34
|
+
border-radius: 4px;
|
|
35
|
+
box-shadow: 0 5px 5px -3px rgba(0, 0, 0, 0.2),
|
|
36
|
+
0 8px 10px 1px rgba(0, 0, 0, 0.14),
|
|
37
|
+
0 3px 14px 2px rgba(0, 0, 0, 0.12);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* Animate items as they're being sorted. */
|
|
41
|
+
.cdk-drop-list-dragging .cdk-drag {
|
|
42
|
+
transition: transform 250ms cubic-bezier(0, 0, 0.2, 1);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* Animate an item that has been dropped. */
|
|
46
|
+
.cdk-drag-animating {
|
|
47
|
+
transition: transform 300ms cubic-bezier(0, 0, 0.2, 1);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.cdk-drag-placeholder {
|
|
51
|
+
opacity: 0;
|
|
52
|
+
}
|
|
53
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<div class="container">
|
|
2
|
+
<h2>To do</h2>
|
|
3
|
+
|
|
4
|
+
<div cdkDropList #todoList="cdkDropList" [cdkDropListData]="todo"
|
|
5
|
+
[cdkDropListConnectedTo]="doneList" class="list" (cdkDropListDropped)="drop($event)">
|
|
6
|
+
<div class="list-item" *ngFor="let item of todo" cdkDrag>{{item}}</div>
|
|
7
|
+
</div>
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
<div class="container">
|
|
11
|
+
<h2>Done</h2>
|
|
12
|
+
|
|
13
|
+
<div cdkDropList #doneList="cdkDropList" [cdkDropListData]="done"
|
|
14
|
+
[cdkDropListConnectedTo]="todoList" class="list" (cdkDropListDropped)="drop($event)">
|
|
15
|
+
<div class="list-item" *ngFor="let item of done" cdkDrag>{{item}}</div>
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { DragDropModule } from '@angular/cdk/drag-drop';
|
|
2
|
+
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
3
|
+
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
|
4
|
+
import { <%= classify(name) %>Component } from './<%= dasherize(name) %>.component';
|
|
5
|
+
|
|
6
|
+
describe('<%= classify(name) %>Component', () => {
|
|
7
|
+
let component: <%= classify(name) %>Component;
|
|
8
|
+
let fixture: ComponentFixture<<%= classify(name) %>Component>;
|
|
9
|
+
|
|
10
|
+
beforeEach(waitForAsync(() => {
|
|
11
|
+
TestBed.configureTestingModule({
|
|
12
|
+
declarations: [ <%= classify(name) %>Component ],
|
|
13
|
+
imports: [
|
|
14
|
+
NoopAnimationsModule,
|
|
15
|
+
DragDropModule,
|
|
16
|
+
]
|
|
17
|
+
}).compileComponents();
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
beforeEach(() => {
|
|
21
|
+
fixture = TestBed.createComponent(<%= classify(name) %>Component);
|
|
22
|
+
component = fixture.componentInstance;
|
|
23
|
+
fixture.detectChanges();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('should compile', () => {
|
|
27
|
+
expect(component).toBeTruthy();
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Component<% if(!!viewEncapsulation) { %>, ViewEncapsulation<% }%><% if(changeDetection !== 'Default') { %>, ChangeDetectionStrategy<% }%> } from '@angular/core';
|
|
2
|
+
import { CdkDragDrop, moveItemInArray, transferArrayItem } from '@angular/cdk/drag-drop';
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
selector: '<%= selector %>',<% if(inlineTemplate) { %>
|
|
6
|
+
template: `
|
|
7
|
+
<%= indentTextContent(resolvedFiles.template, 4) %>
|
|
8
|
+
`,<% } else { %>
|
|
9
|
+
templateUrl: './<%= dasherize(name) %>.component.html',<% } if(inlineStyle) { %>
|
|
10
|
+
styles: [`
|
|
11
|
+
<%= indentTextContent(resolvedFiles.stylesheet, 4) %>
|
|
12
|
+
`],<% } else { %>
|
|
13
|
+
styleUrls: ['./<%= dasherize(name) %>.component.<%= style %>'],<% } %><% if(!!viewEncapsulation) { %>
|
|
14
|
+
encapsulation: ViewEncapsulation.<%= viewEncapsulation %>,<% } if (changeDetection !== 'Default') { %>
|
|
15
|
+
changeDetection: ChangeDetectionStrategy.<%= changeDetection %>,<% } %>
|
|
16
|
+
})
|
|
17
|
+
export class <%= classify(name) %>Component {
|
|
18
|
+
todo = [
|
|
19
|
+
'Get to work',
|
|
20
|
+
'Pick up groceries',
|
|
21
|
+
'Go home',
|
|
22
|
+
'Fall asleep'
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
done = [
|
|
26
|
+
'Get up',
|
|
27
|
+
'Brush teeth',
|
|
28
|
+
'Take a shower',
|
|
29
|
+
'Check e-mail',
|
|
30
|
+
'Walk dog'
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
drop(event: CdkDragDrop<string[]>): void {
|
|
34
|
+
if (event.previousContainer === event.container) {
|
|
35
|
+
moveItemInArray(event.container.data, event.previousIndex, event.currentIndex);
|
|
36
|
+
} else {
|
|
37
|
+
transferArrayItem(event.previousContainer.data,
|
|
38
|
+
event.container.data,
|
|
39
|
+
event.previousIndex,
|
|
40
|
+
event.currentIndex);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import {SchematicTestRunner} from '@angular-devkit/schematics/testing';
|
|
2
|
+
import {COLLECTION_PATH} from '../../paths';
|
|
3
|
+
import {createTestApp, getFileContent} from '../../testing';
|
|
4
|
+
import {Schema} from './schema';
|
|
5
|
+
|
|
6
|
+
describe('CDK drag-drop schematic', () => {
|
|
7
|
+
let runner: SchematicTestRunner;
|
|
8
|
+
|
|
9
|
+
const baseOptions: Schema = {
|
|
10
|
+
name: 'foo',
|
|
11
|
+
// TODO(devversion): rename project to something that is not tied to Material. This involves
|
|
12
|
+
// updating the other tests as well because `createTestApp` is responsible for creating
|
|
13
|
+
// the project.
|
|
14
|
+
project: 'material',
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
runner = new SchematicTestRunner('schematics', COLLECTION_PATH);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('should create drag-drop files and add them to module', async () => {
|
|
22
|
+
const app = await createTestApp(runner);
|
|
23
|
+
const tree = await runner.runSchematicAsync('drag-drop', baseOptions, app).toPromise();
|
|
24
|
+
const moduleContent = getFileContent(tree, '/projects/material/src/app/app.module.ts');
|
|
25
|
+
const files = tree.files;
|
|
26
|
+
|
|
27
|
+
expect(files).toContain('/projects/material/src/app/foo/foo.component.css');
|
|
28
|
+
expect(files).toContain('/projects/material/src/app/foo/foo.component.html');
|
|
29
|
+
expect(files).toContain('/projects/material/src/app/foo/foo.component.spec.ts');
|
|
30
|
+
expect(files).toContain('/projects/material/src/app/foo/foo.component.ts');
|
|
31
|
+
|
|
32
|
+
expect(moduleContent).toMatch(/import.*Foo.*from '.\/foo\/foo.component'/);
|
|
33
|
+
expect(moduleContent).toMatch(/declarations:\s*\[[^\]]+?,\r?\n\s+FooComponent\r?\n/m);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('should add drag-drop module', async () => {
|
|
37
|
+
const app = await createTestApp(runner);
|
|
38
|
+
const tree = await runner.runSchematicAsync('drag-drop', baseOptions, app).toPromise();
|
|
39
|
+
const moduleContent = getFileContent(tree, '/projects/material/src/app/app.module.ts');
|
|
40
|
+
|
|
41
|
+
expect(moduleContent).toContain('DragDropModule');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe('style option', () => {
|
|
45
|
+
it('should respect the option value', async () => {
|
|
46
|
+
const tree = await runner
|
|
47
|
+
.runSchematicAsync(
|
|
48
|
+
'drag-drop',
|
|
49
|
+
{style: 'scss', ...baseOptions},
|
|
50
|
+
await createTestApp(runner),
|
|
51
|
+
)
|
|
52
|
+
.toPromise();
|
|
53
|
+
|
|
54
|
+
expect(tree.files).toContain('/projects/material/src/app/foo/foo.component.scss');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('should respect the deprecated "styleext" option value', async () => {
|
|
58
|
+
let tree = await createTestApp(runner);
|
|
59
|
+
tree.overwrite(
|
|
60
|
+
'angular.json',
|
|
61
|
+
JSON.stringify({
|
|
62
|
+
version: 1,
|
|
63
|
+
defaultProject: 'material',
|
|
64
|
+
projects: {
|
|
65
|
+
material: {
|
|
66
|
+
projectType: 'application',
|
|
67
|
+
schematics: {
|
|
68
|
+
// We need to specify the default component options by overwriting
|
|
69
|
+
// the existing workspace configuration because passing the "styleext"
|
|
70
|
+
// option is no longer supported. Though we want to verify that we
|
|
71
|
+
// properly handle old CLI projects which still use the "styleext" option.
|
|
72
|
+
'@schematics/angular:component': {styleext: 'scss'},
|
|
73
|
+
},
|
|
74
|
+
root: 'projects/material',
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
}),
|
|
78
|
+
);
|
|
79
|
+
tree = await runner.runSchematicAsync('drag-drop', baseOptions, tree).toPromise();
|
|
80
|
+
|
|
81
|
+
expect(tree.files).toContain('/projects/material/src/app/foo/foo.component.scss');
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('should not generate invalid stylesheets', async () => {
|
|
85
|
+
const tree = await runner
|
|
86
|
+
.runSchematicAsync(
|
|
87
|
+
'drag-drop',
|
|
88
|
+
{style: 'styl', ...baseOptions},
|
|
89
|
+
await createTestApp(runner),
|
|
90
|
+
)
|
|
91
|
+
.toPromise();
|
|
92
|
+
|
|
93
|
+
// In this case we expect the schematic to generate a plain "css" file because
|
|
94
|
+
// the component schematics are using CSS style templates which are not compatible
|
|
95
|
+
// with all CLI supported styles (e.g. Stylus or Sass)
|
|
96
|
+
// In this case we expect the schematic to generate a plain "css" file because
|
|
97
|
+
// the component schematics are using CSS style templates which are not compatible
|
|
98
|
+
// with all CLI supported styles (e.g. Stylus or Sass)
|
|
99
|
+
expect(tree.files)
|
|
100
|
+
.withContext('Expected the schematic to generate a plain "css" file.')
|
|
101
|
+
.toContain('/projects/material/src/app/foo/foo.component.css');
|
|
102
|
+
expect(tree.files)
|
|
103
|
+
.not.withContext('Expected the schematic to not generate a "stylus" file')
|
|
104
|
+
.toContain('/projects/material/src/app/foo/foo.component.styl');
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('should fall back to the @schematics/angular:component option value', async () => {
|
|
108
|
+
const tree = await runner
|
|
109
|
+
.runSchematicAsync('drag-drop', baseOptions, await createTestApp(runner, {style: 'less'}))
|
|
110
|
+
.toPromise();
|
|
111
|
+
|
|
112
|
+
expect(tree.files).toContain('/projects/material/src/app/foo/foo.component.less');
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
describe('inlineStyle option', () => {
|
|
117
|
+
it('should respect the option value', async () => {
|
|
118
|
+
const app = await createTestApp(runner);
|
|
119
|
+
const tree = await runner
|
|
120
|
+
.runSchematicAsync('drag-drop', {inlineStyle: true, ...baseOptions}, app)
|
|
121
|
+
.toPromise();
|
|
122
|
+
|
|
123
|
+
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.css');
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('should fall back to the @schematics/angular:component option value', async () => {
|
|
127
|
+
const tree = await runner
|
|
128
|
+
.runSchematicAsync(
|
|
129
|
+
'drag-drop',
|
|
130
|
+
baseOptions,
|
|
131
|
+
await createTestApp(runner, {inlineStyle: true}),
|
|
132
|
+
)
|
|
133
|
+
.toPromise();
|
|
134
|
+
|
|
135
|
+
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.css');
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
describe('inlineTemplate option', () => {
|
|
140
|
+
it('should respect the option value', async () => {
|
|
141
|
+
const app = await createTestApp(runner);
|
|
142
|
+
const tree = await runner
|
|
143
|
+
.runSchematicAsync('drag-drop', {inlineTemplate: true, ...baseOptions}, app)
|
|
144
|
+
.toPromise();
|
|
145
|
+
|
|
146
|
+
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.html');
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('should fall back to the @schematics/angular:component option value', async () => {
|
|
150
|
+
const app = await createTestApp(runner, {inlineTemplate: true});
|
|
151
|
+
const tree = await runner.runSchematicAsync('drag-drop', baseOptions, app).toPromise();
|
|
152
|
+
|
|
153
|
+
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.html');
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
describe('skipTests option', () => {
|
|
158
|
+
it('should respect the option value', async () => {
|
|
159
|
+
const tree = await runner
|
|
160
|
+
.runSchematicAsync(
|
|
161
|
+
'drag-drop',
|
|
162
|
+
{skipTests: true, ...baseOptions},
|
|
163
|
+
await createTestApp(runner),
|
|
164
|
+
)
|
|
165
|
+
.toPromise();
|
|
166
|
+
|
|
167
|
+
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.spec.ts');
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it('should respect the deprecated global "spec" option value', async () => {
|
|
171
|
+
let tree = await createTestApp(runner);
|
|
172
|
+
tree.overwrite(
|
|
173
|
+
'angular.json',
|
|
174
|
+
JSON.stringify({
|
|
175
|
+
version: 1,
|
|
176
|
+
defaultProject: 'material',
|
|
177
|
+
projects: {
|
|
178
|
+
material: {
|
|
179
|
+
projectType: 'application',
|
|
180
|
+
schematics: {
|
|
181
|
+
// We need to specify the default component options by overwriting
|
|
182
|
+
// the existing workspace configuration because passing the "spec"
|
|
183
|
+
// option is no longer supported. Though we want to verify that we
|
|
184
|
+
// properly handle old CLI projects which still use the "spec" option.
|
|
185
|
+
'@schematics/angular:component': {spec: false},
|
|
186
|
+
},
|
|
187
|
+
root: 'projects/material',
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
}),
|
|
191
|
+
);
|
|
192
|
+
tree = await runner.runSchematicAsync('drag-drop', baseOptions, tree).toPromise();
|
|
193
|
+
|
|
194
|
+
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.spec.ts');
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it('should fall back to the @schematics/angular:component option value', async () => {
|
|
198
|
+
const tree = await runner
|
|
199
|
+
.runSchematicAsync('drag-drop', baseOptions, await createTestApp(runner, {skipTests: true}))
|
|
200
|
+
.toPromise();
|
|
201
|
+
|
|
202
|
+
expect(tree.files).not.toContain('/projects/material/src/app/foo/foo.component.spec.ts');
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {chain, noop, Rule, Tree} from '@angular-devkit/schematics';
|
|
10
|
+
import {addModuleImportToModule, buildComponent, findModuleFromOptions} from '../../utils';
|
|
11
|
+
import {Schema} from './schema';
|
|
12
|
+
|
|
13
|
+
/** Scaffolds a new Angular component that uses the Drag and Drop module. */
|
|
14
|
+
export default function (options: Schema): Rule {
|
|
15
|
+
return chain([
|
|
16
|
+
buildComponent(
|
|
17
|
+
{...options},
|
|
18
|
+
{
|
|
19
|
+
template:
|
|
20
|
+
'./__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html.template',
|
|
21
|
+
stylesheet:
|
|
22
|
+
'./__path__/__name@dasherize@if-flat__/__name@dasherize__.component.__style__.template',
|
|
23
|
+
},
|
|
24
|
+
),
|
|
25
|
+
options.skipImport ? noop() : addDragDropModulesToModule(options),
|
|
26
|
+
]);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Adds the required modules to the main module of the CLI project. */
|
|
30
|
+
function addDragDropModulesToModule(options: Schema) {
|
|
31
|
+
return async (host: Tree) => {
|
|
32
|
+
const modulePath = await findModuleFromOptions(host, options);
|
|
33
|
+
addModuleImportToModule(host, modulePath!, 'DragDropModule', '@dugararchit/cdk/drag-drop');
|
|
34
|
+
};
|
|
35
|
+
}
|