Skip to content

Commit

Permalink
build: update to nx 15.6.2
Browse files Browse the repository at this point in the history
  • Loading branch information
dianjuar committed Jan 26, 2023
1 parent eae5230 commit 3cb4211
Show file tree
Hide file tree
Showing 8 changed files with 1,059 additions and 150 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publishment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
release:
environment: production
runs-on: ubuntu-latest
needs: [release-preliminar, e2e-test, angular-e2e-test, test]
needs: [release-preliminar, e2e-test, test]
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup
Expand Down
36 changes: 33 additions & 3 deletions e2e/ngx-deploy-npm-e2e/integration/react-native.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,40 @@
import { initNgxDeployNPMProject, basicSetTestForLibs } from '../utils';
import { runCommand, runNxCommand, uniq } from '@nrwl/nx-plugin/testing';
import {
initNgxDeployNPMProject,
installDependencies,
generateLib,
installNgxDeployNPMProject,
} from '../utils';

describe('React Native', () => {
initNgxDeployNPMProject();

const libName = 'react-native-lib';
const nxPlugin = '@nrwl/react';
const nxPlugin = '@nrwl/react-native';

basicSetTestForLibs(libName, nxPlugin);
installDependencies(nxPlugin);

const uniqLibName = uniq(libName);

generateLib(nxPlugin, uniqLibName);

beforeEach(() => {
runNxCommand(`generate ${nxPlugin}:init`);
runCommand('yarn add -D @babel/preset-react @nrwl/web');
}, 120000);

beforeEach(() => {
runNxCommand(
`generate ${nxPlugin}:component layout --project=${uniqLibName} --export`
);
});

// Install the project
installNgxDeployNPMProject();

it('should publish the lib', () => {
expect(() => {
runNxCommand(`deploy ${uniqLibName} --dry-run`);
}).not.toThrow();
}, 120000);
});
5 changes: 4 additions & 1 deletion e2e/ngx-deploy-npm-e2e/integration/react.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@ describe('React', () => {
const libName = 'react-lib';
const nxPlugin = '@nrwl/react';

basicSetTestForLibs(libName, nxPlugin);
basicSetTestForLibs(libName, nxPlugin, {
libGeneratorCommandOptions:
'--style css --bundler vite --unitTestRunner jest',
});
});
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,26 @@
"@commitlint/cli": "17.2.0",
"@commitlint/config-conventional": "17.2.0",
"@jscutlery/semver": "2.29.3",
"@nrwl/cli": "15.2.4",
"@nrwl/devkit": "15.2.4",
"@nrwl/eslint-plugin-nx": "15.2.4",
"@nrwl/jest": "15.2.4",
"@nrwl/js": "15.2.4",
"@nrwl/linter": "15.2.4",
"@nrwl/nx-plugin": "15.2.4",
"@nrwl/workspace": "15.2.4",
"@nrwl/cli": "15.6.2",
"@nrwl/devkit": "15.6.2",
"@nrwl/eslint-plugin-nx": "15.6.2",
"@nrwl/jest": "15.6.2",
"@nrwl/js": "15.6.2",
"@nrwl/linter": "15.6.2",
"@nrwl/nx-plugin": "15.6.2",
"@nrwl/workspace": "15.6.2",
"@types/jest": "29.2.3",
"@types/node": "18.11.18",
"@typescript-eslint/eslint-plugin": "^5.10.2",
"@typescript-eslint/parser": "^5.10.2",
"commitizen": "4.2.5",
"create-nx-workspace": "^15.0.13",
"create-nx-workspace": "^15.5.1",
"cz-conventional-changelog": "3.3.0",
"eslint": "^8.8.0",
"eslint-config-prettier": "8.5.0",
"husky": "8.0.2",
"jest": "29.3.1",
"nx": "15.2.4",
"nx": "15.6.2",
"prettier": "2.8.0",
"pretty-quick": "^3.1.3",
"ts-jest": "29.0.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/ngx-deploy-npm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"node": ">=14.0.0"
},
"dependencies": {
"@nrwl/devkit": "15.2.3"
"@nrwl/devkit": "15.6.2"
},
"ng-add": {
"save": "devDependencies"
Expand Down
21 changes: 21 additions & 0 deletions packages/ngx-deploy-npm/src/executors/deploy/actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ describe('Deploy Angular apps', () => {
target: {
executor: 'ngx-deploy-npm',
},
projectGraph: {},
} as nxDevKit.ExecutorContext;

outputPath = `${context.root}/dist/path/to/project/${PROJECT}`;
Expand All @@ -60,6 +61,18 @@ describe('Deploy Angular apps', () => {
},
} as AsyncIterableIterator<{ success: boolean }>)
);

jest
.spyOn(nxDevKit, 'parseTargetString')
.mockImplementation(targetString => {
const targetArr = targetString.split(':');

return {
project: targetArr[0],
target: targetArr[1],
configuration: targetArr[2],
};
});
});

it('should invoke the builder', async () => {
Expand Down Expand Up @@ -124,5 +137,13 @@ describe('Deploy Angular apps', () => {
deploy(mockEngine, context, getMockBuildTarget(), {})
).rejects.toThrowError(NotAbleToGetDistFolderPathError);
});

it('should throw if context.projectGraph is undefined', async () => {
delete context.projectGraph;

await expect(() =>
deploy(mockEngine, context, getMockBuildTarget(), {})
).rejects.toThrowError('context.projectGraph is undefined');
});
});
});
10 changes: 9 additions & 1 deletion packages/ngx-deploy-npm/src/executors/deploy/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@ export default async function deploy(
buildTarget: BuildTarget,
options: DeployExecutorOptions
) {
const targetDescription = parseTargetString(buildTarget.name);
// This should be removed on V17. context.projectGraph is going to be required
if (!context.projectGraph) {
throw new Error('context.projectGraph is undefined');
}

const targetDescription = parseTargetString(
buildTarget.name,
context.projectGraph
);

if (options.noBuild) {
logger.info(`📦 Skipping build`);
Expand Down
Loading

0 comments on commit 3cb4211

Please sign in to comment.