Skip to content

Commit

Permalink
Merge branch 'master' into fix/merge-implicits-properly
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz authored Aug 29, 2023
2 parents 0ea078a + 903e96b commit 54dcaa8
Show file tree
Hide file tree
Showing 23 changed files with 655 additions and 520 deletions.
2 changes: 1 addition & 1 deletion nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"default": {
"runner": "nx-cloud",
"options": {
"accessToken": "NDg1NTA3MTAtOGFmZC00YmIwLTk2Y2MtOTkzNzc4ZTczYTlkfHJlYWQtb25seQ==",
"accessToken": "YmZiOWQyNzctOThiZC00MjYwLWI3YTAtZDA3MDg4YWY1YTExfHJlYWQ=",
"cacheableOperations": [
"build",
"lint-base",
Expand Down
30 changes: 15 additions & 15 deletions packages/express/src/generators/application/application.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,25 @@ describe('app', () => {
let appTree: Tree;

beforeEach(() => {
appTree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
appTree = createTreeWithEmptyWorkspace();
});

it('should generate files', async () => {
await applicationGenerator(appTree, {
name: 'myNodeApp',
projectNameAndRootFormat: 'as-provided',
} as Schema);

const mainFile = appTree.read('apps/my-node-app/src/main.ts').toString();
const mainFile = appTree.read('my-node-app/src/main.ts').toString();
expect(mainFile).toContain(`import express from 'express';`);

const tsconfig = readJson(appTree, 'apps/my-node-app/tsconfig.json');
const tsconfig = readJson(appTree, 'my-node-app/tsconfig.json');
expect(tsconfig).toMatchInlineSnapshot(`
{
"compilerOptions": {
"esModuleInterop": true,
},
"extends": "../../tsconfig.base.json",
"extends": "../tsconfig.base.json",
"files": [],
"include": [],
"references": [
Expand All @@ -38,11 +39,11 @@ describe('app', () => {
}
`);

const eslintrcJson = readJson(appTree, 'apps/my-node-app/.eslintrc.json');
const eslintrcJson = readJson(appTree, 'my-node-app/.eslintrc.json');
expect(eslintrcJson).toMatchInlineSnapshot(`
{
"extends": [
"../../.eslintrc.json",
"../.eslintrc.json",
],
"ignorePatterns": [
"!**/*",
Expand Down Expand Up @@ -79,14 +80,15 @@ describe('app', () => {
it('should add types to the tsconfig.app.json', async () => {
await applicationGenerator(appTree, {
name: 'myNodeApp',
projectNameAndRootFormat: 'as-provided',
} as Schema);
const tsconfig = readJson(appTree, 'apps/my-node-app/tsconfig.app.json');
const tsconfig = readJson(appTree, 'my-node-app/tsconfig.app.json');
expect(tsconfig.compilerOptions.types).toContain('express');
expect(tsconfig).toMatchInlineSnapshot(`
{
"compilerOptions": {
"module": "commonjs",
"outDir": "../../dist/out-tsc",
"outDir": "../dist/out-tsc",
"types": [
"node",
"express",
Expand All @@ -110,23 +112,21 @@ describe('app', () => {
await applicationGenerator(appTree, {
name: 'myNodeApp',
js: true,
projectNameAndRootFormat: 'as-provided',
} as Schema);

expect(appTree.exists('apps/my-node-app/src/main.js')).toBeTruthy();
expect(appTree.read('apps/my-node-app/src/main.js').toString()).toContain(
expect(appTree.exists('my-node-app/src/main.js')).toBeTruthy();
expect(appTree.read('my-node-app/src/main.js').toString()).toContain(
`import express from 'express';`
);

const tsConfig = readJson(appTree, 'apps/my-node-app/tsconfig.json');
const tsConfig = readJson(appTree, 'my-node-app/tsconfig.json');
expect(tsConfig.compilerOptions).toEqual({
allowJs: true,
esModuleInterop: true,
});

const tsConfigApp = readJson(
appTree,
'apps/my-node-app/tsconfig.app.json'
);
const tsConfigApp = readJson(appTree, 'my-node-app/tsconfig.app.json');
expect(tsConfigApp.include).toEqual(['src/**/*.ts', 'src/**/*.js']);
expect(tsConfigApp.exclude).toEqual([
'jest.config.ts',
Expand Down
9 changes: 2 additions & 7 deletions packages/express/src/generators/init/init.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
addDependenciesToPackageJson,
readJson,
NxJsonConfiguration,
Tree,
} from '@nx/devkit';
import { addDependenciesToPackageJson, readJson, Tree } from '@nx/devkit';
import { expressVersion } from '../../utils/versions';
import initGenerator from './init';
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
Expand All @@ -12,7 +7,7 @@ describe('init', () => {
let tree: Tree;

beforeEach(() => {
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
tree = createTreeWithEmptyWorkspace();
});

it('should add dependencies', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,17 @@ describe('convert to swc', () => {
};

beforeAll(() => {
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
tree.write('/apps/.gitignore', '');
tree.write('/libs/.gitignore', '');
tree = createTreeWithEmptyWorkspace();
tree.write('/.gitignore', '');
tree.write('/.gitignore', '');
});

it('should convert tsc to swc', async () => {
await jsLibraryGenerator(tree, {
...defaultLibGenerationOptions,
name: 'tsc-lib',
bundler: 'tsc',
projectNameAndRootFormat: 'as-provided',
});

expect(
Expand All @@ -49,7 +50,7 @@ describe('convert to swc', () => {
)
).toEqual(true);
expect(tree.read('package.json', 'utf-8')).toContain('@swc/core');
expect(tree.read('libs/tsc-lib/package.json', 'utf-8')).toContain(
expect(tree.read('tsc-lib/package.json', 'utf-8')).toContain(
'@swc/helpers'
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ if (swcJestConfig.swcrc === undefined) {
module.exports = {
displayName: 'my-lib',
preset: '../../jest.preset.js',
preset: '../jest.preset.js',
transform: {
'^.+\\\\.[tj]s$': ['@swc/jest', swcJestConfig],
},
moduleFileExtensions: ['ts', 'js', 'html'],
testEnvironment: 'jsdom',
coverageDirectory: '../../coverage/libs/my-lib',
coverageDirectory: '../coverage/my-lib',
};
"
`;
Loading

0 comments on commit 54dcaa8

Please sign in to comment.