-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
73 changed files
with
2,813 additions
and
1,105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ | |
/dist | ||
/coverage | ||
|
||
/.nx/cache | ||
/.nx/cache | ||
examples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test:$6FrCaT/v0dwE:autocreated 2020-03-25T19:10:50.254Z |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# path to a directory with all packages | ||
storage: ../dist/local-registry/storage | ||
|
||
auth: | ||
htpasswd: | ||
file: ./htpasswd | ||
|
||
# a list of other known repositories we can talk to | ||
uplinks: | ||
npmjs: | ||
url: https://registry.npmjs.org/ | ||
maxage: 60m | ||
max_fails: 20 | ||
fail_timeout: 2m | ||
yarn: | ||
url: https://registry.yarnpkg.com | ||
maxage: 60m | ||
max_fails: 20 | ||
fail_timeout: 2m | ||
|
||
packages: | ||
'@*/*': | ||
# scoped packages | ||
access: $all | ||
publish: $all | ||
unpublish: $all | ||
proxy: npmjs | ||
|
||
'**': | ||
# allow all users (including non-authenticated users) to read and | ||
# publish all packages | ||
access: $all | ||
|
||
# allow all users (including non-authenticated users) to publish/publish packages | ||
publish: $all | ||
unpublish: $all | ||
|
||
# if package is not available locally, proxy requests to 'yarn' registry | ||
proxy: npmjs | ||
|
||
# log settings | ||
logs: | ||
type: stdout | ||
format: pretty | ||
level: warn | ||
|
||
publish: | ||
allow_offline: true # set offline to true to allow publish offline |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,116 @@ | ||
import { | ||
checkFilesExist, | ||
ensureNxProject, | ||
runNxCommand, | ||
} from '@nx/plugin/testing'; | ||
import { execSync } from 'child_process'; | ||
import { readJsonFile, workspaceRoot, writeJsonFile } from '@nx/devkit'; | ||
import { ExecSyncOptionsWithStringEncoding, execSync } from 'child_process'; | ||
import { ensureDirSync, removeSync, existsSync } from 'fs-extra'; | ||
import { dirname, join } from 'path'; | ||
|
||
describe('nx-react-workshop e2e', () => { | ||
describe('migrations', () => { | ||
describe('migrations for alternative option', () => { | ||
it('should run the migrations', () => { | ||
ensureNxProject('@nrwl/nx-react-workshop', 'dist/libs/nx-react-workshop'); | ||
expect(() => checkFilesExist(`libs`)).not.toThrow(); | ||
createNewWorkspace(); | ||
|
||
expect(() => checkFilesExist(`node_modules/.bin/nx`)).not.toThrow(); | ||
}, 120000); | ||
for (let i = 1; i < 22; i++) { | ||
|
||
for (let i = 1; i < 23; i++) { | ||
it(`should complete lab ${i}`, () => { | ||
runNxCommand( | ||
`generate @nrwl/nx-react-workshop:complete-labs --lab=${i}` | ||
`generate @nrwl/nx-react-workshop:complete-labs --lab=${i} --option=option1` | ||
); | ||
runNxCommand('migrate --run-migrations=migrations.json --verbose'); | ||
runNxCommand( | ||
'run-many --target=e2e --parallel=false --exclude=internal-plugin-e2e' | ||
); | ||
runNxCommand('run-many --target=lint --parallel=false'); | ||
}); | ||
} | ||
}); | ||
|
||
describe('migrations for deployment path', () => { | ||
it('should run the migrations', () => { | ||
createNewWorkspace(); | ||
|
||
expect(() => checkFilesExist(`node_modules/.bin/nx`)).not.toThrow(); | ||
}, 120000); | ||
|
||
for (let i = 1; i < 23; i++) { | ||
it(`should complete lab ${i}`, () => { | ||
runNxCommand( | ||
`generate @nrwl/nx-react-workshop:complete-labs --lab=${i} --option=option2` | ||
); | ||
runNxCommand('migrate --run-migrations=migrations.json'); | ||
runNxCommand('run-many --target=e2e --parallel=false'); | ||
runNxCommand( | ||
'run-many --target=e2e --parallel=false --exclude=internal-plugin-e2e' | ||
); | ||
runNxCommand('run-many --target=lint --parallel=false'); | ||
}); | ||
} | ||
}); | ||
}); | ||
|
||
const scope = `bg-hoard`; | ||
|
||
function tmpProjPath() { | ||
return join(process.cwd(), 'tmp', 'nx-e2e', scope); | ||
} | ||
|
||
function createNewWorkspace() { | ||
const localTmpDir = dirname(tmpProjPath()); | ||
ensureDirSync(localTmpDir); | ||
removeSync(tmpProjPath()); | ||
// create new workspace | ||
execSync( | ||
`node ${require.resolve( | ||
'nx' | ||
)} new ${scope} --nx-workspace-root=${localTmpDir} --no-interactive --skip-install --collection=@nx/workspace --npmScope=${scope} --preset=apps --packageManager=npm`, | ||
{ | ||
cwd: localTmpDir, | ||
} | ||
); | ||
// patch package.json | ||
const path = join(tmpProjPath(), 'package.json'); | ||
const json = readJsonFile(path); | ||
json.devDependencies[ | ||
'@nrwl/nx-react-workshop' | ||
] = `file:${workspaceRoot}/dist/libs/nx-react-workshop`; | ||
writeJsonFile(path, json); | ||
// install dependencies | ||
execSync('npm install', { | ||
cwd: tmpProjPath(), | ||
stdio: ['ignore', 'ignore', 'ignore'], | ||
}); | ||
} | ||
|
||
function checkFilesExist(...expectedPaths) { | ||
expectedPaths.forEach((path) => { | ||
const filePath = join(tmpProjPath(), path); | ||
if (!execSync(filePath)) { | ||
throw new Error(`'${filePath}' does not exist`); | ||
} | ||
}); | ||
} | ||
|
||
function runNxCommand(command): string { | ||
function _runNxCommand(c) { | ||
const execSyncOptions: ExecSyncOptionsWithStringEncoding = { | ||
cwd: tmpProjPath(), | ||
env: process.env, | ||
encoding: 'utf-8', | ||
}; | ||
if (existsSync(join(tmpProjPath(), 'package.json'))) { | ||
return execSync(`npx nx ${c}`, execSyncOptions); | ||
} else { | ||
return execSync(`./nx %${c}`, execSyncOptions); | ||
} | ||
} | ||
try { | ||
return _runNxCommand(command) | ||
.toString() | ||
.replace( | ||
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, | ||
'' | ||
); | ||
} catch (e) { | ||
console.log(e.stdout.toString(), e.stderr.toString()); | ||
throw e; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.