diff --git a/package.json b/package.json index 3e0217ad1da24..ef02879eba21b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@nrwl/nx-source", - "version": "8.11.2", + "version": "8.12.0-beta.7", "description": "Extensible Dev Tools for Monorepos", "homepage": "https://nx.dev", "main": "index.js", diff --git a/packages/create-nx-workspace/bin/create-nx-plugin.ts b/packages/create-nx-plugin/bin/create-nx-plugin.ts similarity index 98% rename from packages/create-nx-workspace/bin/create-nx-plugin.ts rename to packages/create-nx-plugin/bin/create-nx-plugin.ts index 08153e76e8e0b..fb77ae765840a 100644 --- a/packages/create-nx-workspace/bin/create-nx-plugin.ts +++ b/packages/create-nx-plugin/bin/create-nx-plugin.ts @@ -150,7 +150,7 @@ function determinePluginName(parsedArgs) { .prompt([ { name: 'PluginName', - message: `Plugin name `, + message: `Plugin name `, type: 'string' } ]) diff --git a/packages/create-nx-plugin/bin/shared.ts b/packages/create-nx-plugin/bin/shared.ts new file mode 100644 index 0000000000000..6dca29e76d722 --- /dev/null +++ b/packages/create-nx-plugin/bin/shared.ts @@ -0,0 +1,68 @@ +import * as path from 'path'; +import { execSync } from 'child_process'; +import { output } from '@nrwl/workspace/src/utils/output'; + +export function showNxWarning(workspaceName: string) { + try { + const pathToRunNxCommand = path.resolve(process.cwd(), workspaceName); + execSync('nx --version', { + cwd: pathToRunNxCommand, + stdio: ['ignore', 'ignore', 'ignore'] + }); + } catch (e) { + // no nx found + output.addVerticalSeparator(); + output.note({ + title: `Nx CLI is not installed globally.`, + bodyLines: [ + `This means that you might have to use "yarn nx" or "npm nx" to execute commands in the workspace.`, + `Run "yarn global add @nrwl/cli" or "npm install -g @nrwl/cli" to be able to execute command directly.` + ] + }); + } +} + +export function determinePackageManager() { + let packageManager = getPackageManagerFromAngularCLI(); + if (packageManager === 'npm' || isPackageManagerInstalled(packageManager)) { + return packageManager; + } + + if (isPackageManagerInstalled('yarn')) { + return 'yarn'; + } + + if (isPackageManagerInstalled('pnpm')) { + return 'pnpm'; + } + + return 'npm'; +} + +function getPackageManagerFromAngularCLI(): string { + // If you have Angular CLI installed, read Angular CLI config. + // If it isn't installed, default to 'yarn'. + try { + return execSync('ng config -g cli.packageManager', { + stdio: ['ignore', 'pipe', 'ignore'], + timeout: 500 + }) + .toString() + .trim(); + } catch (e) { + return 'yarn'; + } +} + +function isPackageManagerInstalled(packageManager: string) { + let isInstalled = false; + try { + execSync(`${packageManager} --version`, { + stdio: ['ignore', 'ignore', 'ignore'] + }); + isInstalled = true; + } catch (e) { + /* do nothing */ + } + return isInstalled; +} diff --git a/packages/create-nx-plugin/package.json b/packages/create-nx-plugin/package.json new file mode 100644 index 0000000000000..4508200d42256 --- /dev/null +++ b/packages/create-nx-plugin/package.json @@ -0,0 +1,36 @@ +{ + "name": "create-nx-plugin", + "version": "0.0.2", + "description": "Extensible Dev Tools for Monorepos", + "repository": { + "type": "git", + "url": "git+https://github.com/nrwl/nx.git" + }, + "keywords": [ + "Monorepo", + "Angular", + "React", + "Web", + "Node", + "Nest", + "Jest", + "Cypress", + "CLI" + ], + "bin": { + "create-nx-plugin": "./bin/create-nx-plugin.js" + }, + "author": "Victor Savkin", + "license": "MIT", + "bugs": { + "url": "https://github.com/nrwl/nx/issues" + }, + "homepage": "https://nx.dev", + "dependencies": { + "@nrwl/workspace": "*", + "tmp": "0.0.33", + "yargs-parser": "10.0.0", + "yargs": "^11.0.0", + "inquirer": "^6.3.1" + } +} diff --git a/packages/create-nx-workspace/package.json b/packages/create-nx-workspace/package.json index 2bb0a4fd983e6..a89ce4a959d01 100644 --- a/packages/create-nx-workspace/package.json +++ b/packages/create-nx-workspace/package.json @@ -18,8 +18,7 @@ "CLI" ], "bin": { - "create-nx-workspace": "./bin/create-nx-workspace.js", - "create-nx-plugin": "./bin/create-nx-plugin.js" + "create-nx-workspace": "./bin/create-nx-workspace.js" }, "author": "Victor Savkin", "license": "MIT", diff --git a/scripts/build.sh b/scripts/build.sh index 9966fe6791105..db2d5c37f936d 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -29,7 +29,7 @@ rm -rf build/packages/angular/bundles/nrwl-angular-testing.umd.min.js.bak rsync -a --exclude=*.ts packages/ build/packages chmod +x build/packages/create-nx-workspace/bin/create-nx-workspace.js -chmod +x build/packages/create-nx-workspace/bin/create-nx-plugin.js +chmod +x build/packages/create-nx-plugin/bin/create-nx-plugin.js chmod +x build/packages/cli/bin/nx.js chmod +x build/packages/tao/index.js @@ -43,6 +43,7 @@ cp README.md build/packages/builders cp README.md build/packages/schematics cp README.md build/packages/nx cp README.md build/packages/create-nx-workspace +cp README.md build/packages/create-nx-plugin cp README.md build/packages/workspace cp README.md build/packages/node cp README.md build/packages/express @@ -65,6 +66,7 @@ cp LICENSE build/packages/builders cp LICENSE build/packages/schematics cp LICENSE build/packages/nx cp LICENSE build/packages/create-nx-workspace +cp LICENSE build/packages/create-nx-plugin cp LICENSE build/packages/workspace cp LICENSE build/packages/node cp LICENSE build/packages/express diff --git a/scripts/check-imports.js b/scripts/check-imports.js index a7216bd27559f..baeb25dee7ed5 100644 --- a/scripts/check-imports.js +++ b/scripts/check-imports.js @@ -27,6 +27,7 @@ function allFilesInDir(dirName) { function check() { const exceptions = [ 'packages/create-nx-workspace/bin/create-nx-workspace.ts', + 'packages/create-nx-plugin/bin/create-nx-plugin.ts', 'packages/web/src/builders/build/build.impl.ts', 'packages/web/src/builders/build/build.impl.spec.ts', 'packages/web/src/utils/web.config.ts', @@ -43,6 +44,7 @@ function check() { const files = [ ...allFilesInDir('packages/create-nx-workspace'), + ...allFilesInDir('packages/create-nx-plugin'), ...allFilesInDir('packages/cypress'), ...allFilesInDir('packages/express'), ...allFilesInDir('packages/jest'), diff --git a/scripts/nx-release.js b/scripts/nx-release.js index a7bbda5046f6f..6751b7e73a16b 100755 --- a/scripts/nx-release.js +++ b/scripts/nx-release.js @@ -151,6 +151,7 @@ const options = { 'package.json', 'build/npm/schematics/package.json', 'build/npm/create-nx-workspace/package.json', + 'build/npm/create-nx-plugin/package.json', 'build/npm/jest/package.json', 'build/npm/cypress/package.json', 'build/npm/storybook/package.json', diff --git a/scripts/package.sh b/scripts/package.sh index b065ca5bea7b5..91eb12487cc9e 100755 --- a/scripts/package.sh +++ b/scripts/package.sh @@ -18,33 +18,33 @@ cd build/packages if [[ "$OSTYPE" == "darwin"* ]]; then sed -i "" "s|exports.nxVersion = '\*';|exports.nxVersion = '$NX_VERSION';|g" {react,next,web,jest,node,express,nest,cypress,storybook,angular,workspace}/src/utils/versions.js - sed -i "" "s|\*|$NX_VERSION|g" {schematics,react,next,web,jest,node,express,nest,cypress,storybook,angular,workspace,cli,linter,bazel,tao,eslint-plugin-nx,create-nx-workspace,nx-plugin}/package.json + sed -i "" "s|\*|$NX_VERSION|g" {schematics,react,next,web,jest,node,express,nest,cypress,storybook,angular,workspace,cli,linter,bazel,tao,eslint-plugin-nx,create-nx-workspace,create-nx-plugin,nx-plugin}/package.json sed -i "" "s|NX_VERSION|$NX_VERSION|g" create-nx-workspace/bin/create-nx-workspace.js sed -i "" "s|ANGULAR_CLI_VERSION|$ANGULAR_CLI_VERSION|g" create-nx-workspace/bin/create-nx-workspace.js sed -i "" "s|TYPESCRIPT_VERSION|$TYPESCRIPT_VERSION|g" create-nx-workspace/bin/create-nx-workspace.js sed -i "" "s|PRETTIER_VERSION|$PRETTIER_VERSION|g" create-nx-workspace/bin/create-nx-workspace.js - sed -i "" "s|NX_VERSION|$NX_VERSION|g" create-nx-workspace/bin/create-nx-plugin.js - sed -i "" "s|ANGULAR_CLI_VERSION|$ANGULAR_CLI_VERSION|g" create-nx-workspace/bin/create-nx-plugin.js - sed -i "" "s|TYPESCRIPT_VERSION|$TYPESCRIPT_VERSION|g" create-nx-workspace/bin/create-nx-plugin.js - sed -i "" "s|PRETTIER_VERSION|$PRETTIER_VERSION|g" create-nx-workspace/bin/create-nx-plugin.js + sed -i "" "s|NX_VERSION|$NX_VERSION|g" create-nx-plugin/bin/create-nx-plugin.js + sed -i "" "s|ANGULAR_CLI_VERSION|$ANGULAR_CLI_VERSION|g" create-nx-plugin/bin/create-nx-plugin.js + sed -i "" "s|TYPESCRIPT_VERSION|$TYPESCRIPT_VERSION|g" create-nx-plugin/bin/create-nx-plugin.js + sed -i "" "s|PRETTIER_VERSION|$PRETTIER_VERSION|g" create-nx-plugin/bin/create-nx-plugin.js else sed -i "s|exports.nxVersion = '\*';|exports.nxVersion = '$NX_VERSION';|g" {react,next,web,jest,node,express,nest,cypress,storybook,angular,workspace}/src/utils/versions.js - sed -i "s|\*|$NX_VERSION|g" {schematics,react,next,web,jest,node,express,nest,cypress,storybook,angular,workspace,cli,linter,bazel,tao,eslint-plugin-nx,create-nx-workspace,nx-plugin}/package.json + sed -i "s|\*|$NX_VERSION|g" {schematics,react,next,web,jest,node,express,nest,cypress,storybook,angular,workspace,cli,linter,bazel,tao,eslint-plugin-nx,create-nx-workspace,create-nx-plugin,nx-plugin}/package.json sed -i "s|NX_VERSION|$NX_VERSION|g" create-nx-workspace/bin/create-nx-workspace.js sed -i "s|ANGULAR_CLI_VERSION|$ANGULAR_CLI_VERSION|g" create-nx-workspace/bin/create-nx-workspace.js sed -i "s|TYPESCRIPT_VERSION|$TYPESCRIPT_VERSION|g" create-nx-workspace/bin/create-nx-workspace.js sed -i "s|PRETTIER_VERSION|$PRETTIER_VERSION|g" create-nx-workspace/bin/create-nx-workspace.js - sed -i "s|NX_VERSION|$NX_VERSION|g" create-nx-workspace/bin/create-nx-plugin.js - sed -i "s|ANGULAR_CLI_VERSION|$ANGULAR_CLI_VERSION|g" create-nx-workspace/bin/create-nx-plugin.js - sed -i "s|TYPESCRIPT_VERSION|$TYPESCRIPT_VERSION|g" create-nx-workspace/bin/create-nx-plugin.js - sed -i "s|PRETTIER_VERSION|$PRETTIER_VERSION|g" create-nx-workspace/bin/create-nx-plugin.js + sed -i "s|NX_VERSION|$NX_VERSION|g" create-nx-plugin/bin/create-nx-plugin.js + sed -i "s|ANGULAR_CLI_VERSION|$ANGULAR_CLI_VERSION|g" create-nx-plugin/bin/create-nx-plugin.js + sed -i "s|TYPESCRIPT_VERSION|$TYPESCRIPT_VERSION|g" create-nx-plugin/bin/create-nx-plugin.js + sed -i "s|PRETTIER_VERSION|$PRETTIER_VERSION|g" create-nx-plugin/bin/create-nx-plugin.js fi if [[ $NX_VERSION == "*" ]]; then if [[ "$OSTYPE" == "darwin"* ]]; then - sed -E -i "" "s|\"@nrwl\/([^\"]+)\": \"\\*\"|\"@nrwl\/\1\": \"file:$PWD\/\1\"|" {schematics,jest,web,react,next,node,express,nest,cypress,storybook,angular,workspace,linter,bazel,cli,tao,eslint-plugin-nx,create-nx-workspace,nx-plugin}/package.json + sed -E -i "" "s|\"@nrwl\/([^\"]+)\": \"\\*\"|\"@nrwl\/\1\": \"file:$PWD\/\1\"|" {schematics,jest,web,react,next,node,express,nest,cypress,storybook,angular,workspace,linter,bazel,cli,tao,eslint-plugin-nx,create-nx-workspace,create-nx-plugin,nx-plugin}/package.json else echo $PWD - sed -E -i "s|\"@nrwl\/([^\"]+)\": \"\\*\"|\"@nrwl\/\1\": \"file:$PWD\/\1\"|" {schematics,jest,web,react,next,node,express,nest,cypress,storybook,angular,workspace,linter,bazel,cli,tao,eslint-plugin-nx,create-nx-workspace,nx-plugin}/package.json + sed -E -i "s|\"@nrwl\/([^\"]+)\": \"\\*\"|\"@nrwl\/\1\": \"file:$PWD\/\1\"|" {schematics,jest,web,react,next,node,express,nest,cypress,storybook,angular,workspace,linter,bazel,cli,tao,eslint-plugin-nx,create-nx-workspace,create-nx-plugin,nx-plugin}/package.json fi fi