Skip to content

Commit

Permalink
feat(angular): add node and npm preconditions (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-bompart authored Apr 9, 2021
1 parent 9ed203b commit 028a422
Show file tree
Hide file tree
Showing 12 changed files with 476 additions and 144 deletions.
22 changes: 11 additions & 11 deletions packages/cli-e2e/docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
version: "3.9"
version: '3.9'

services:
runner:
image: "coveo-cli-e2e-image"
container_name: "coveo-cli-e2e-container"
image: 'coveo-cli-e2e-image'
container_name: 'coveo-cli-e2e-container'
cap_add:
- "IPC_LOCK"
- "SYS_ADMIN"
env_file: "../.env"
- 'IPC_LOCK'
- 'SYS_ADMIN'
env_file: '../.env'
privileged: true
ports:
- "9229:9229"
- '9229:9229'
volumes:
- ../../..:/home/notGroot/cli
networks:
- node-network
command: "/bin/bash"
command: '/bin/bash'
tty: true
stdin_open: true
verdaccio:
image: verdaccio/verdaccio
container_name: "verdaccio"
container_name: 'verdaccio'
networks:
- node-network
environment:
- VERDACCIO_PORT=4873
ports:
- "4873:4873"
- '4873:4873'
volumes:
- "./config:/verdaccio/conf"
- './config:/verdaccio/conf'
networks:
node-network:
driver: bridge
141 changes: 130 additions & 11 deletions packages/cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
"cli-ux": "^5.5.1",
"coveo.analytics": "^2.18.4",
"create-react-app": "^4.0.3",
"dedent": "^0.7.0",
"exponential-backoff": "^3.1.0",
"fs-extra": "^9.1.0",
"isomorphic-fetch": "^3.0.0",
"isomorphic-form-data": "^2.0.0",
"semver": "^7.3.4",
"ts-dedent": "^2.1.1",
"tslib": "^1"
},
"devDependencies": {
Expand All @@ -33,7 +33,6 @@
"@coveo/vue-cli-plugin-typescript": "^0.7.0",
"@oclif/dev-cli": "^1.26.0",
"@oclif/test": "^1",
"@types/dedent": "^0.7.0",
"@types/fs-extra": "^9.0.6",
"@types/jest": "^26.0.22",
"@types/node": "^10",
Expand Down
14 changes: 13 additions & 1 deletion packages/cli/src/commands/ui/create/angular.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,18 @@ import {getPackageVersion} from '../../../lib/utils/misc';
import {
Preconditions,
IsAuthenticated,
IsNodeVersionInRange,
} from '../../../lib/decorators/preconditions/';
import {IsNpmVersionInRange} from '../../../lib/decorators/preconditions/npm';

export default class Angular extends Command {
static templateName = '@coveo/angular';
/**
* Requirements Based on https://angular.io/guide/setup-local
* and https://www.npmjs.com/package/@angular/cli package.json engines section.
*/
static requiredNodeVersion = '>=12.13.0 <15.0.0';
static requiredNpmVersion = '^6.11.0 || ^7.5.6';

static description =
'Create a Coveo Headless-powered search page with the Angular web framework. See https://docs.coveo.com/headless and https://angular.io/.';
Expand All @@ -36,7 +44,11 @@ export default class Angular extends Command {
{name: 'name', description: 'The target application name.', required: true},
];

@Preconditions(IsAuthenticated())
@Preconditions(
IsAuthenticated(),
IsNodeVersionInRange(Angular.requiredNodeVersion),
IsNpmVersionInRange(Angular.requiredNpmVersion)
)
async run() {
const {args, flags} = this.parse(Angular);
await this.createProject(args.name, flags.defaults);
Expand Down
9 changes: 5 additions & 4 deletions packages/cli/src/commands/ui/create/react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@ import {join} from 'path';
import {
Preconditions,
IsAuthenticated,
IsNodeVersionAbove,
IsNodeVersionInRange,
IsNpxInstalled,
} from '../../../lib/decorators/preconditions';

export default class React extends Command {
static templateName = '@coveo/cra-template';
/**
* Node.JS v10.16.0 is the first version that included NPX (via NPM).
* Future requirement should be based on https://create-react-app.dev/docs/getting-started/#creating-an-app.
* Future requirement should be based on https://create-react-app.dev/docs/getting-started/#creating-an-app
* and https://www.npmjs.com/package/create-react-app package.json engines section.
*/
static requiredNodeVersion = '10.16.0';
static requiredNodeVersion = '>=10.16.0';

static description =
'Create a Coveo Headless-powered search page with the React web framework. See https://docs.coveo.com/headless and https://reactjs.org/.';
Expand All @@ -46,7 +47,7 @@ export default class React extends Command {

@Preconditions(
IsAuthenticated(),
IsNodeVersionAbove(React.requiredNodeVersion),
IsNodeVersionInRange(React.requiredNodeVersion),
IsNpxInstalled()
)
async run() {
Expand Down
Loading

0 comments on commit 028a422

Please sign in to comment.