Skip to content

Commit

Permalink
fix: add assert-not-using-ts-solution-setup to the generators (#1140)
Browse files Browse the repository at this point in the history
* chore(capacitor): add assert-not-using-ts-solution-setup to the generators

* chore(ionic-angular): add assert-not-using-ts-solution-setup to the generators

* chore(ionic-react): add assert-not-using-ts-solution-setup to the generators

* chore(preact): add assert-not-using-ts-solution-setup to the generators

* chore(solid): add assert-not-using-ts-solution-setup to the generators

* chore(stencil): add assert-not-using-ts-solution-setup to the generators

* chore(svelte): add assert-not-using-ts-solution-setup to the generators

* chore(sveltekit): add assert-not-using-ts-solution-setup to the generators
  • Loading branch information
pawel-twardziak authored Oct 15, 2024
1 parent 2fbc5a8 commit 1e45be4
Show file tree
Hide file tree
Showing 30 changed files with 94 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/capacitor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
},
"peerDependencies": {
"@nx/devkit": "^20.0.0",
"@nx/js": "^20.0.0",
"nx": "^20.0.0"
}
}
3 changes: 3 additions & 0 deletions packages/capacitor/src/generators/configuration/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ import { normalizeOptions } from './lib/normalize-options';
import { updateProjectGitignore } from './lib/update-project-gitignore';
import { updateProjectPackageJson } from './lib/update-project-package-json';
import { CapacitorConfigurationSchema } from './schema';
import { assertNotUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';

export async function capacitorConfigurationGenerator(
host: Tree,
options: CapacitorConfigurationSchema
) {
assertNotUsingTsSolutionSetup(host, '@nxext/capacitor', 'configuration');

const normalizedOptions = normalizeOptions(host, options);
const installTask = addDependencies(host);
addCapacitorConfig(host, normalizedOptions);
Expand Down
3 changes: 2 additions & 1 deletion packages/ionic-angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
},
"peerDependencies": {
"@nx/devkit": "^20.0.0",
"@nx/angular": "^20.0.0"
"@nx/angular": "^20.0.0",
"@nx/js": "^20.0.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ import { ConfigurationGeneratorSchema } from './schema';
import { addFiles, removeFiles } from './lib/files';
import { normalizeOptions } from './lib/normalize-options';
import { updateJestConfig } from './lib/update-jest-config';
import { assertNotUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';

export async function configurationGenerator(
host: Tree,
schema: ConfigurationGeneratorSchema
) {
assertNotUsingTsSolutionSetup(host, '@nxext/ionic-angular', 'configuration');

const options = await normalizeOptions(host, schema);
const installTask = addDependencies(host);
removeFiles(host, options);
Expand Down
3 changes: 2 additions & 1 deletion packages/ionic-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"tslib": "^2.3.0"
},
"peerDependencies": {
"@nx/devkit": "^20.0.0"
"@nx/devkit": "^20.0.0",
"@nx/js": "^20.0.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ import { addFiles, deleteFiles } from './lib/files';
import { normalizeOptions } from './lib/normalize-options';
import { updateWorkspace } from './lib/update-workspace';
import { ConfigurationGeneratorSchema } from './schema';
import { assertNotUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';

export async function configurationGenerator(
host: Tree,
options: ConfigurationGeneratorSchema
) {
assertNotUsingTsSolutionSetup(host, '@nxext/ionic-react', 'configuration');

const normalizedOptions = normalizeOptions(host, options);
const installTask = addDependencies(host);
addFiles(host, normalizedOptions);
Expand Down
3 changes: 3 additions & 0 deletions packages/preact/src/generators/application/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
determineProjectNameAndRootOptions,
ensureProjectName,
} from '@nx/devkit/src/generators/project-name-and-root-utils';
import { assertNotUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';

async function normalizeOptions(
tree: Tree,
Expand Down Expand Up @@ -97,6 +98,8 @@ export async function applicationGenerator(
tree: Tree,
schema: PreactApplicationSchema
) {
assertNotUsingTsSolutionSetup(tree, '@nxext/preact', 'application');

const options = await normalizeOptions(tree, schema);

const initTask = await initGenerator(tree, { ...options, skipFormat: true });
Expand Down
3 changes: 3 additions & 0 deletions packages/preact/src/generators/component/component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { addExportsToBarrel } from './lib/add-exports-to-barrel';
import { createComponentInProject } from './lib/create-component-in-project';
import { Tree } from '@nx/devkit';
import { assertNotUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';

export interface PreactComponentSchema {
name: string;
Expand All @@ -13,6 +14,8 @@ export async function componentGenerator(
tree: Tree,
options: PreactComponentSchema
) {
assertNotUsingTsSolutionSetup(tree, '@nxext/preact', 'component');

createComponentInProject(tree, options);
addExportsToBarrel(tree, options);
}
Expand Down
3 changes: 3 additions & 0 deletions packages/preact/src/generators/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ import { formatFiles, Tree, runTasksInSerial } from '@nx/devkit';
import { addJestPlugin } from './lib/add-jest-plugin';
import { addCypressPlugin } from './lib/add-cypress-plugin';
import { updateDependencies } from './lib/add-dependencies';
import { assertNotUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';

export async function initGenerator(host: Tree, options: Schema) {
assertNotUsingTsSolutionSetup(host, '@nxext/preact', 'init');

const installTask = updateDependencies(host);
const jestTask = await addJestPlugin(host, options);
const cypressTask = await addCypressPlugin(host, options);
Expand Down
3 changes: 3 additions & 0 deletions packages/preact/src/generators/library/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
determineProjectNameAndRootOptions,
ensureProjectName,
} from '@nx/devkit/src/generators/project-name-and-root-utils';
import { assertNotUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';

async function normalizeOptions(
tree: Tree,
Expand Down Expand Up @@ -89,6 +90,8 @@ export async function libraryGenerator(
host: Tree,
schema: PreactLibrarySchema
) {
assertNotUsingTsSolutionSetup(host, '@nxext/preact', 'library');

const options = await normalizeOptions(host, schema);
if (options.publishable === true && !schema.importPath) {
throw new Error(
Expand Down
3 changes: 3 additions & 0 deletions packages/solid/src/generators/application/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
determineProjectNameAndRootOptions,
ensureProjectName,
} from '@nx/devkit/src/generators/project-name-and-root-utils';
import { assertNotUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';

async function normalizeOptions<T extends Schema = Schema>(
host: Tree,
Expand Down Expand Up @@ -85,6 +86,8 @@ export async function applicationGenerator(
}

export async function applicationGeneratorInternal(tree: Tree, schema: Schema) {
assertNotUsingTsSolutionSetup(tree, '@nxext/solid', 'application');

const options = await normalizeOptions(tree, schema);

const initTask = await initGenerator(tree, { ...options, skipFormat: true });
Expand Down
3 changes: 3 additions & 0 deletions packages/solid/src/generators/component/component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { addExportsToBarrel } from './lib/add-exports-to-barrel';
import { createComponentInProject } from './lib/create-component-in-project';
import { Tree } from '@nx/devkit';
import { assertNotUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';

export interface SolidComponentSchema {
name: string;
Expand All @@ -13,6 +14,8 @@ export async function componentGenerator(
tree: Tree,
options: SolidComponentSchema
) {
assertNotUsingTsSolutionSetup(tree, '@nxext/solid', 'component');

createComponentInProject(tree, options);
addExportsToBarrel(tree, options);
}
Expand Down
3 changes: 3 additions & 0 deletions packages/solid/src/generators/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ import {
import { addJestPlugin } from './lib/add-jest-plugin';
import { addCypressPlugin } from './lib/add-cypress-plugin';
import { updateDependencies } from './lib/add-dependencies';
import { assertNotUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';

export async function initGenerator(host: Tree, schema: Schema) {
assertNotUsingTsSolutionSetup(host, '@nxext/solid', 'init');

const tasks: GeneratorCallback[] = [];

if (!schema.unitTestRunner || schema.unitTestRunner === 'jest') {
Expand Down
3 changes: 3 additions & 0 deletions packages/solid/src/generators/library/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
ensureProjectName,
} from '@nx/devkit/src/generators/project-name-and-root-utils';
import { createOrEditViteConfig } from '@nx/vite';
import { assertNotUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';

async function normalizeOptions(
host: Tree,
Expand Down Expand Up @@ -77,6 +78,8 @@ export async function libraryGeneratorInternal(
host: Tree,
schema: SolidLibrarySchema
) {
assertNotUsingTsSolutionSetup(host, '@nxext/solid', 'library');

const options = await normalizeOptions(host, schema);
if (options.publishable === true && !schema.importPath) {
throw new Error(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ import { isBuildableStencilProject } from '../../utils/utillities';
import { AddOutputtargetSchematicSchema } from './schema';
import { addAngularGenerator } from './add-angular/generator';
import { addReactGenerator } from './add-react/generator';
import { assertNotUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';

export async function outputtargetGenerator(
host: Tree,
options: AddOutputtargetSchematicSchema
) {
assertNotUsingTsSolutionSetup(host, '@nxext/stencil', 'add-outputtarget');

const projectConfig = readProjectConfiguration(host, options.projectName);
const tasks = [];

Expand Down
3 changes: 3 additions & 0 deletions packages/stencil/src/generators/application/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
determineProjectNameAndRootOptions,
ensureProjectName,
} from '@nx/devkit/src/generators/project-name-and-root-utils';
import { assertNotUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';

async function normalizeOptions(
host: Tree,
Expand Down Expand Up @@ -98,6 +99,8 @@ export async function applicationGenerator(
host: Tree,
schema: RawApplicationSchema
) {
assertNotUsingTsSolutionSetup(host, '@nxext/stencil', 'application');

const options = await normalizeOptions(host, schema);
const initTask = await initGenerator(host, {
...options,
Expand Down
3 changes: 3 additions & 0 deletions packages/stencil/src/generators/component/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import { join } from 'path';
import { insertStatement } from '../../utils/insert-statement';
import { getProjectTsImportPath } from '../storybook-configuration/generator';
import { assertNotUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';

export interface ComponentSchema {
name: string;
Expand All @@ -21,6 +22,8 @@ export interface ComponentSchema {
}

export async function componentGenerator(host: Tree, options: ComponentSchema) {
assertNotUsingTsSolutionSetup(host, '@nxext/stencil', 'component');

if (!/[-]/.test(options.name)) {
throw new Error(stripIndents`
"${options.name}" tag must contain a dash (-) to work as a valid web component. Please refer to
Expand Down
3 changes: 3 additions & 0 deletions packages/stencil/src/generators/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ import { formatFiles, Tree } from '@nx/devkit';
import { runTasksInSerial } from '@nx/devkit';
import { addCypress } from './lib/add-cypress';
import { addJest } from './lib/add-jest';
import { assertNotUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';

export async function initGenerator<T extends InitSchema>(
host: Tree,
options: T
) {
assertNotUsingTsSolutionSetup(host, '@nxext/stencil', 'init');

const dependenciesTask = addDependenciesByApptype(host, options.appType);
const styleDependenciesTask = addStyledDependencies(host, options);
const addPuppeteerTask = await addPuppeteer(host, options);
Expand Down
3 changes: 3 additions & 0 deletions packages/stencil/src/generators/library/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
determineProjectNameAndRootOptions,
ensureProjectName,
} from '@nx/devkit/src/generators/project-name-and-root-utils';
import { assertNotUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';

async function normalizeOptions(
host: Tree,
Expand Down Expand Up @@ -81,6 +82,8 @@ function createFiles(host: Tree, options: LibrarySchema) {
}

export async function libraryGenerator(host: Tree, schema: RawLibrarySchema) {
assertNotUsingTsSolutionSetup(host, '@nxext/stencil', 'library');

const options = await normalizeOptions(host, schema);

if (options.publishable === true && !options.importPath) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
} from '../../utils/targets';
import { AppType } from '../../utils/typings';
import { getProjectTsImportPath } from '../storybook-configuration/generator';
import { assertNotUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';

function normalize(
host: Tree,
Expand Down Expand Up @@ -59,6 +60,8 @@ export async function makeLibBuildableGenerator(
host: Tree,
schema: MakeLibBuildableSchema
) {
assertNotUsingTsSolutionSetup(host, '@nxext/stencil', 'make-lib-buildable');

const options = normalize(host, schema);

updateProjectConfig(host, options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { updateDependencies } from './lib/add-dependencies';
import { updateLintConfig } from './lib/update-lint-config';
import { StorybookConfigureSchema } from './schema';
import { getNpmScope } from '@nx/js/src/utils/package-json/get-npm-scope';
import { assertNotUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';

/**
* With Nx `npmScope` (eg: nx-workspace) and `projectName` (eg: nx-project), returns a path portion to be used for import statements or
Expand All @@ -43,6 +44,12 @@ export async function storybookConfigurationGenerator(
host: Tree,
rawSchema: StorybookConfigureSchema
) {
assertNotUsingTsSolutionSetup(
host,
'@nxext/stencil',
'storybook-configuration'
);

const tasks: GeneratorCallback[] = [];
const uiFramework = '@storybook/html-webpack5';
const options = normalizeSchema(rawSchema);
Expand Down
3 changes: 3 additions & 0 deletions packages/svelte/src/generators/application/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { addVite } from './lib/add-vite';
import { createApplicationFiles } from './lib/create-project-files';
import { normalizeOptions } from './lib/normalize-options';
import { createOrEditViteConfig } from '@nx/vite';
import { assertNotUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';

export async function applicationGenerator(
host: Tree,
Expand All @@ -26,6 +27,8 @@ export async function applicationGenerator(
}

export async function applicationGeneratorInternal(host: Tree, schema: Schema) {
assertNotUsingTsSolutionSetup(host, '@nxext/svelte', 'application');

const options = await normalizeOptions(host, schema);

const initTask = await initGenerator(host, { ...options, skipFormat: true });
Expand Down
3 changes: 3 additions & 0 deletions packages/svelte/src/generators/component/component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { addExportsToBarrel } from './lib/add-exports-to-barrel';
import { createComponentInProject } from './lib/create-component-in-project';
import { Tree } from '@nx/devkit';
import { assertNotUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';

export interface SvelteComponentSchema {
name: string;
Expand All @@ -13,6 +14,8 @@ export async function componentGenerator(
tree: Tree,
options: SvelteComponentSchema
) {
assertNotUsingTsSolutionSetup(tree, '@nxext/svelte', 'component');

createComponentInProject(tree, options);
addExportsToBarrel(tree, options);
}
Expand Down
3 changes: 3 additions & 0 deletions packages/svelte/src/generators/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ import { addCypressPlugin } from './lib/add-cypress-plugin';
import { updateDependencies } from './lib/add-dependencies';
import { addLinterPlugin } from './lib/add-linter-plugin';
import { addPluginToNxJson } from '../utils/add-plugin-to-nx-json';
import { assertNotUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';

export async function initGenerator(host: Tree, schema: Schema) {
assertNotUsingTsSolutionSetup(host, '@nxext/svelte', 'init');

const tasks: GeneratorCallback[] = [];

const jestTask = await addJestPlugin(host, schema);
Expand Down
3 changes: 3 additions & 0 deletions packages/svelte/src/generators/library/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { createProjectFiles } from './lib/create-project-files';
import { addVitest } from './lib/add-vitest';
import { normalizeOptions } from './lib/normalize-options';
import { createOrEditViteConfig } from '@nx/vite';
import { assertNotUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';

function updateLibPackageNpmScope(host: Tree, options: NormalizedSchema) {
return updateJson(host, `${options.projectRoot}/package.json`, (json) => {
Expand All @@ -23,6 +24,8 @@ export async function libraryGenerator(
host: Tree,
schema: SvelteLibrarySchema
) {
assertNotUsingTsSolutionSetup(host, '@nxext/svelte', 'library');

const options = await normalizeOptions(host, schema);
if (options.publishable === true && !schema.importPath) {
throw new Error(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,18 @@ import { Linter } from '@nx/eslint';
import { StorybookConfigureSchema } from './schema';
import { svelteLoaderVersion } from '../utils/versions';
import { updateMainJs } from './lib/update-main-js';
import { assertNotUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';

export async function configurationGenerator(
host: Tree,
schema: StorybookConfigureSchema
) {
assertNotUsingTsSolutionSetup(
host,
'@nxext/svelte',
'storybook-configuration'
);

const uiFramework = '@storybook/svelte-vite';
const options = normalizeSchema(schema);
const tasks: GeneratorCallback[] = [];
Expand Down
Loading

0 comments on commit 1e45be4

Please sign in to comment.