Skip to content

Commit

Permalink
feat: initial support for nx 18
Browse files Browse the repository at this point in the history
  • Loading branch information
gperdomor committed Feb 6, 2024
1 parent 1aa2081 commit 18cfa11
Show file tree
Hide file tree
Showing 23 changed files with 2,597 additions and 2,546 deletions.
18 changes: 12 additions & 6 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,22 @@
"inputs": ["production", "^production"],
"cache": true
},
"lint": {
"@nx/eslint:lint": {
"inputs": ["default", "{workspaceRoot}/.eslintrc.json", "{workspaceRoot}/.eslintignore"],
"cache": true
},
"test": {
"@nx/jest:jest": {
"inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"],
"cache": true
},
"e2e": {
"cache": true
"cache": true,
"options": {
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
}
},
"namedInputs": {
Expand Down
4,837 changes: 2,439 additions & 2,398 deletions package-lock.json

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@nx-tools/source",
"description": "NX Tools plugins",
"version": "5.1.0",
"version": "5.2.0",
"license": "MIT",
"scripts": {
"commit": "cz",
Expand All @@ -15,7 +15,7 @@
"dependencies": {
"@actions/exec": "1.1.1",
"@actions/github": "5.1.1",
"@nx/devkit": "17.0.2",
"@nx/devkit": "18.0.2",
"@renovate/pep440": "1.0.0",
"@swc/helpers": "0.5.3",
"ci-info": "3.8.0",
Expand All @@ -37,21 +37,21 @@
"@commitlint/config-conventional": "17.6.7",
"@commitlint/config-nx-scopes": "17.6.4",
"@commitlint/cz-commitlint": "17.6.7",
"@nx/eslint-plugin": "17.0.2",
"@nx/jest": "17.0.2",
"@nx/js": "17.0.2",
"@nx/plugin": "17.0.2",
"@nx/workspace": "17.0.2",
"@nx/eslint-plugin": "18.0.2",
"@nx/jest": "18.0.2",
"@nx/js": "18.0.2",
"@nx/plugin": "18.0.2",
"@nx/workspace": "18.0.2",
"@prisma/client": "4.16.2",
"@swc-node/register": "1.6.8",
"@swc/cli": "~0.1.62",
"@swc/core": "1.3.95",
"@types/jest": "29.4.4",
"@types/node": "18.16.19",
"@typescript-eslint/eslint-plugin": "5.62.0",
"@typescript-eslint/parser": "5.62.0",
"@types/node": "18.19.14",
"@typescript-eslint/eslint-plugin": "6.21.0",
"@typescript-eslint/parser": "6.21.0",
"commitizen": "4.3.0",
"eslint": "8.46.0",
"eslint": "8.48.0",
"eslint-config-prettier": "9.0.0",
"husky": "8.0.3",
"is-ci": "3.0.1",
Expand All @@ -60,14 +60,14 @@
"jest-environment-node": "29.4.3",
"lint-staged": "13.2.3",
"mocked-env": "1.3.5",
"nx": "17.0.2",
"nx": "18.0.2",
"prettier": "2.8.8",
"ts-jest": "29.1.1",
"ts-node": "10.9.1",
"typescript": "5.1.6",
"typescript": "5.3.3",
"validate-branch-name": "1.3.0",
"verdaccio": "^5.0.4",
"@nx/eslint": "17.0.2"
"@nx/eslint": "18.0.2"
},
"nx": {
"includedScripts": []
Expand Down
4 changes: 2 additions & 2 deletions packages/ci-context/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "@nx-tools/ci-context",
"version": "5.1.0",
"version": "5.2.0",
"type": "commonjs",
"author": "gperdomor <gperdomor@gmail.com>",
"repository": "https://github.com/gperdomor/nx-tools",
"bugs": "https://github.com/gperdomor/nx-tools/issues",
"license": "MIT",
"dependencies": {
"@nx-tools/core": "5.1.0",
"@nx-tools/core": "5.2.0",
"ci-info": "3.8.0",
"@octokit/openapi-types": "12.11.0",
"@actions/github": "5.1.1",
Expand Down
14 changes: 2 additions & 12 deletions packages/ci-context/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,13 @@
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["packages/ci-context/**/*.ts", "packages/ci-context/package.json"]
}
"outputs": ["{options.outputFile}"]
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "packages/ci-context/jest.config.ts",
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
"jestConfig": "packages/ci-context/jest.config.ts"
}
}
},
Expand Down
8 changes: 4 additions & 4 deletions packages/container-metadata/package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{
"name": "@nx-tools/container-metadata",
"version": "5.1.0",
"version": "5.2.0",
"type": "commonjs",
"author": "gperdomor <gperdomor@gmail.com>",
"repository": "https://github.com/gperdomor/nx-tools",
"bugs": "https://github.com/gperdomor/nx-tools/issues",
"license": "MIT",
"dependencies": {
"@nx-tools/core": "5.1.0",
"@nx-tools/core": "5.2.0",
"csv-parse": "5.4.0",
"@nx-tools/ci-context": "5.1.0",
"@nx-tools/ci-context": "5.2.0",
"@renovate/pep440": "1.0.0",
"handlebars": "4.7.7",
"moment-timezone": "0.5.43",
"semver": "7.5.4"
},
"peerDependencies": {
"@nx/devkit": "^16.0.0 || ^17.0.0",
"@nx/devkit": "^16.0.0 || ^17.0.0 || ^18.0.0",
"dotenv": ">=10.0.0",
"tslib": "^2.5.3"
}
Expand Down
14 changes: 2 additions & 12 deletions packages/container-metadata/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,13 @@
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["packages/container-metadata/**/*.ts", "packages/container-metadata/package.json"]
}
"outputs": ["{options.outputFile}"]
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "packages/container-metadata/jest.config.ts",
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
"jestConfig": "packages/container-metadata/jest.config.ts"
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nx-tools/core",
"version": "5.1.0",
"version": "5.2.0",
"type": "commonjs",
"author": "gperdomor <gperdomor@gmail.com>",
"repository": "https://github.com/gperdomor/nx-tools",
Expand All @@ -12,7 +12,7 @@
"ci-info": "3.8.0"
},
"peerDependencies": {
"@nx/devkit": "^16.0.0 || ^17.0.0",
"@nx/devkit": "^16.0.0 || ^17.0.0 || ^18.0.0",
"tslib": "^2.5.3"
}
}
14 changes: 2 additions & 12 deletions packages/core/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,13 @@
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["packages/core/**/*.ts", "packages/core/package.json"]
}
"outputs": ["{options.outputFile}"]
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "packages/core/jest.config.ts",
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
"jestConfig": "packages/core/jest.config.ts"
}
}
},
Expand Down
6 changes: 3 additions & 3 deletions packages/nx-container/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nx-tools/nx-container",
"version": "5.1.0",
"version": "5.2.0",
"author": "gperdomor <gperdomor@gmail.com>",
"repository": "https://github.com/gperdomor/nx-tools",
"bugs": "https://github.com/gperdomor/nx-tools/issues",
Expand All @@ -9,15 +9,15 @@
"generators": "./generators.json",
"executors": "./executors.json",
"dependencies": {
"@nx-tools/core": "5.1.0",
"@nx-tools/core": "5.2.0",
"tmp": "0.2.1",
"csv-parse": "5.4.0",
"semver": "7.5.4",
"handlebars": "4.7.7"
},
"peerDependencies": {
"dotenv": ">=10.0.0",
"@nx/devkit": "^16.0.0 || ^17.0.0",
"@nx/devkit": "^16.0.0 || ^17.0.0 || ^18.0.0",
"tslib": "^2.5.3"
}
}
19 changes: 2 additions & 17 deletions packages/nx-container/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,13 @@
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": [
"packages/nx-container/**/*.ts",
"packages/nx-container/generators.json",
"packages/nx-container/executors.json",
"packages/nx-container/package.json"
]
}
"outputs": ["{options.outputFile}"]
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "packages/nx-container/jest.config.ts",
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
"jestConfig": "packages/nx-container/jest.config.ts"
}
}
},
Expand Down
3 changes: 3 additions & 0 deletions packages/nx-container/src/generators/init/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const DEFAULT_ENGINE = 'docker';

export const DEFAULT_TEMPLATE = 'empty';
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FROM docker.io/node:lts-alpine as deps
RUN apk add --no-cache libc6-compat
WORKDIR /usr/src/app
COPY dist/apps/<%= projectName %>/package*.json ./
RUN npm install --only=production
RUN npm install --omit=dev

# Production image, copy all the files and run nest
FROM docker.io/node:lts-alpine as runner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FROM docker.io/node:lts-alpine as deps
RUN apk add --no-cache libc6-compat
WORKDIR /usr/src/app
COPY dist/apps/<%= projectName %>/package*.json ./
RUN npm install --only=production
RUN npm install --omit=dev

# Production image, copy all the files and run next
FROM docker.io/node:lts-alpine as runner
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM docker.io/nginx:stable-alpine
COPY dist/apps/<%= projectName %>/* /usr/share/nginx/html/
COPY dist/apps/<%= projectName %>/* /usr/share/nginx/html/
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
57 changes: 57 additions & 0 deletions packages/nx-container/src/generators/init/generator.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { Tree, addProjectConfiguration, readProjectConfiguration } from '@nx/devkit';
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
import { initGenerator } from './generator';
import { InitGeneratorSchema } from './schema';

describe('init generator', () => {
let tree: Tree;

beforeEach(() => {
tree = createTreeWithEmptyWorkspace();
});

test.each([
[1, 'myapp', 'docker', undefined, 'docker', undefined],
[2, 'myapp', 'docker', 'nest', 'docker', 'CMD ["dumb-init", "node", "main.js"]'],
[3, 'myapp', 'docker', 'next', 'docker', 'ENV NEXT_TELEMETRY_DISABLED 1'],
[4, 'myapp', 'docker', 'nginx', 'docker', 'FROM docker.io/nginx:stable-alpine'],
[5, 'myapp', 'podman', undefined, 'podman', undefined],
[6, 'myapp', 'podman', 'nest', 'podman', 'CMD ["dumb-init", "node", "main.js"]'],
[7, 'myapp', 'podman', 'next', 'podman', 'ENV NEXT_TELEMETRY_DISABLED 1'],
[8, 'myapp', 'podman', 'nginx', 'podman', 'FROM docker.io/nginx:stable-alpine'],
[9, 'myapp', 'kaniko', undefined, 'kaniko', undefined],
[10, 'myapp', 'kaniko', 'nest', 'kaniko', 'CMD ["dumb-init", "node", "main.js"]'],
[11, 'myapp', 'kaniko', 'next', 'kaniko', 'ENV NEXT_TELEMETRY_DISABLED 1'],
[12, 'myapp', 'kaniko', 'nginx', 'kaniko', 'FROM docker.io/nginx:stable-alpine'],
])(
'%d - given projectName=%s, engine=%s and template=%s - should generate configuration for %s executor and proper dockerfile',
async (_, projectName, engine: any, template: any, executor, text) => {
const options: InitGeneratorSchema = { project: projectName, engine, template };

addProjectConfiguration(tree, projectName, { root: `apps/${projectName}` });

await initGenerator(tree, options);

const project = readProjectConfiguration(tree, projectName);
expect(tree.exists('./apps/myapp/Dockerfile')).toBeTruthy();

const contents = tree.read('./apps/myapp/Dockerfile', 'utf-8');

if (text) {
expect(contents.includes(text)).toBeTruthy();
expect(contents.includes(`COPY dist/apps/${projectName}/`)).toBeTruthy();
} else {
expect(contents).toBe('');
}

expect(project.targets).toMatchObject({
container: {
executor: `@nx-tools/nx-container:build`,
options: {
engine: executor,
},
},
});
}
);
});
Loading

0 comments on commit 18cfa11

Please sign in to comment.