Skip to content

Commit

Permalink
Add Nx11 generators for vue schematics
Browse files Browse the repository at this point in the history
  • Loading branch information
DominikPieper authored and ZachJW34 committed Apr 20, 2021
1 parent dbdfb48 commit 35389e7
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 4 deletions.
4 changes: 4 additions & 0 deletions libs/vue/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export { applicationGenerator } from './schematics/application/schematic';
export { libraryGenerator } from './schematics/library/schematic';
export { componentGenerator } from './schematics/component/schematic';
export { vuexGenerator } from './schematics/vuex/schematic';
11 changes: 10 additions & 1 deletion libs/vue/src/schematics/application/schematic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
updateWorkspace,
} from '@nrwl/workspace';
import { appsDir } from '@nrwl/workspace/src/utils/ast-utils';
import { wrapAngularDevkitSchematic } from '@nrwl/devkit/ngcli-adapter';
import { ApplicationSchematicSchema } from './schema';
import { checkPeerDeps } from '../../utils';

Expand Down Expand Up @@ -303,7 +304,9 @@ function addBabel(options: NormalizedSchema) {
]);
}

export default function (options: ApplicationSchematicSchema): Rule {
export function applicationSchematic(
options: ApplicationSchematicSchema
): Rule {
return (host: Tree, context: SchematicContext) => {
checkPeerDeps(context, options);
const normalizedOptions = normalizeOptions(host, options);
Expand Down Expand Up @@ -385,3 +388,9 @@ export default function (options: ApplicationSchematicSchema): Rule {
]);
};
}

export default applicationSchematic;
export const applicationGenerator = wrapAngularDevkitSchematic(
'@nx-plus/vue',
'application'
);
9 changes: 8 additions & 1 deletion libs/vue/src/schematics/component/schematic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
toClassName,
toFileName,
} from '@nrwl/workspace';
import { wrapAngularDevkitSchematic } from '@nrwl/devkit/ngcli-adapter';
import { ComponentSchematicSchema } from './schema';

interface NormalizedSchema extends ComponentSchematicSchema {
Expand Down Expand Up @@ -55,7 +56,7 @@ function createComponent(options: NormalizedSchema): Rule {
);
}

export default function (schema: ComponentSchematicSchema): Rule {
export function componentSchematic(schema: ComponentSchematicSchema): Rule {
return (host: Tree) => {
const options = normalizeOptions(host, schema);
return chain([
Expand All @@ -64,3 +65,9 @@ export default function (schema: ComponentSchematicSchema): Rule {
]);
};
}

export default componentSchematic;
export const componentGenerator = wrapAngularDevkitSchematic(
'@nx-plus/vue',
'component'
);
9 changes: 8 additions & 1 deletion libs/vue/src/schematics/library/schematic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
readJsonInTree,
NxJson,
} from '@nrwl/workspace';
import { wrapAngularDevkitSchematic } from '@nrwl/devkit/ngcli-adapter';
import { libsDir } from '@nrwl/workspace/src/utils/ast-utils';
import { LibrarySchematicSchema } from './schema';

Expand Down Expand Up @@ -309,7 +310,7 @@ function updateTsConfig(options: NormalizedSchema): Rule {
]);
}

export default function (options: LibrarySchematicSchema): Rule {
export function librarySchematic(options: LibrarySchematicSchema): Rule {
return (host: Tree) => {
const normalizedOptions = normalizeOptions(host, options);
return chain([
Expand Down Expand Up @@ -354,3 +355,9 @@ export default function (options: LibrarySchematicSchema): Rule {
]);
};
}

export default librarySchematic;
export const libraryGenerator = wrapAngularDevkitSchematic(
'@nx-plus/vue',
'library'
);
6 changes: 5 additions & 1 deletion libs/vue/src/schematics/vuex/schematic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
InsertChange,
insertImport,
} from '@nrwl/workspace/src/utils/ast-utils';
import { wrapAngularDevkitSchematic } from '@nrwl/devkit/ngcli-adapter';
import * as semver from 'semver';
import * as ts from 'typescript';
import { VuexSchematicSchema } from './schema';
Expand Down Expand Up @@ -135,7 +136,7 @@ function addStoreToMain(options: VuexSchematicSchema, isVue3: boolean): Rule {
};
}

export default function (options: VuexSchematicSchema): Rule {
export function vuexSchematic(options: VuexSchematicSchema): Rule {
const vue = loadModule('vue', appRootPath);
const isVue3 = semver.major(vue.version) === 3;

Expand All @@ -146,3 +147,6 @@ export default function (options: VuexSchematicSchema): Rule {
formatFiles(options),
]);
}

export default vuexSchematic;
export const vuexGenerator = wrapAngularDevkitSchematic('@nx-plus/vue', 'vuex');

0 comments on commit 35389e7

Please sign in to comment.