forked from angular-schule/ngx-deploy-starter
-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
20 changed files
with
508 additions
and
728 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
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 +1 @@ | ||
18 | ||
20 |
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,30 +1,17 @@ | ||
import { checkFilesExist, runNxCommand } from '@nx/plugin/testing'; | ||
import { | ||
generateLib, | ||
initNgxDeployNPMProject, | ||
installDependencies, | ||
installNgxDeployNPMProject, | ||
} from '../utils'; | ||
import { checkFilesExist, runNxCommand, uniq } from '@nx/plugin/testing'; | ||
import { setup } from '../utils'; | ||
|
||
describe('build', () => { | ||
const publishableLib = 'basic-lib'; | ||
const nxPlugin = '@nx/node'; | ||
const setUp = (libName: string) => | ||
setup([{ name: libName, generator: '@nx/node' }]); | ||
|
||
initNgxDeployNPMProject(); | ||
installDependencies(nxPlugin); | ||
it('should build the lib due to the `dependsOn` option created on the target', async () => { | ||
const [lib] = await setUp(uniq('basic-lib')); | ||
|
||
generateLib(nxPlugin, publishableLib, `--dir="libs"`); | ||
|
||
// Install the project | ||
installNgxDeployNPMProject( | ||
`--project="${publishableLib}" --distFolderPath="dist/libs/${publishableLib}"` | ||
); | ||
|
||
it('should build the lib due to the `dependsOn` option created on the target', () => { | ||
runNxCommand(`deploy ${publishableLib} --dry-run`); | ||
runNxCommand(`deploy ${lib.name} --dry-run`); | ||
|
||
expect(() => | ||
checkFilesExist(`dist/libs/${publishableLib}/package.json`) | ||
checkFilesExist(`dist/libs/${lib.name}/package.json`) | ||
).not.toThrow(); | ||
}, 120000); | ||
}); |
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,90 +1,14 @@ | ||
import { | ||
ensureNxProject, | ||
runNxCommand, | ||
runPackageManagerInstall, | ||
uniq, | ||
} from '@nx/plugin/testing'; | ||
import * as fs from 'fs'; | ||
import { runNxCommand, uniq } from '@nx/plugin/testing'; | ||
import { setup } from '../utils'; | ||
|
||
describe('Minimal Project', () => { | ||
const setup = async () => { | ||
ensureNxProject('ngx-deploy-npm', 'dist/packages/ngx-deploy-npm'); | ||
runPackageManagerInstall(); | ||
|
||
const uniqLibName = uniq('minimal-lib'); | ||
|
||
const { libRoot } = await createMinimalLib(uniqLibName); | ||
|
||
// Install the project | ||
runNxCommand( | ||
`generate ngx-deploy-npm:install --project="${uniqLibName}" --dist-folder-path="${libRoot}"` | ||
); | ||
|
||
async function createMinimalLib(libName: string) { | ||
// Create Lib | ||
const libRoot = `libs/${libName}`; | ||
const libRootAbsolutePath = `./tmp/nx-e2e/proj/${libRoot}`; | ||
|
||
// Create the lib folder | ||
await fs.promises.mkdir(libRootAbsolutePath, { | ||
recursive: true, | ||
}); | ||
|
||
const createProjectJsonPromise = fs.promises.writeFile( | ||
`${libRootAbsolutePath}/project.json`, | ||
generateProjectJSON(libName), | ||
'utf8' | ||
); | ||
const createPackageJsonPromise = fs.promises.writeFile( | ||
`${libRootAbsolutePath}/package.json`, | ||
generatePackageJSON(libName), | ||
'utf8' | ||
); | ||
const createUniqueFilePromise = fs.promises.writeFile( | ||
`${libRootAbsolutePath}/hello-world.js`, | ||
"console.log('Hello World!');", | ||
'utf8' | ||
); | ||
await Promise.all([ | ||
createProjectJsonPromise, | ||
createPackageJsonPromise, | ||
createUniqueFilePromise, | ||
]); | ||
|
||
return { libRoot }; | ||
|
||
function generateProjectJSON(projectName: string): string { | ||
const content = { | ||
name: projectName, | ||
$schema: '../../node_modules/nx/schemas/project-schema.json', | ||
projectType: 'library', | ||
}; | ||
|
||
return JSON.stringify(content, null, 2); | ||
} | ||
|
||
function generatePackageJSON(projectName: string): string { | ||
const content = { | ||
name: `@mock-domain/${projectName}`, | ||
description: 'Minimal LIb', | ||
version: '1.0.0', | ||
}; | ||
|
||
return JSON.stringify(content, null, 2); | ||
} | ||
} | ||
|
||
return { | ||
libRoot, | ||
uniqLibName, | ||
}; | ||
}; | ||
|
||
it('should publish the lib', async () => { | ||
const { uniqLibName } = await setup(); | ||
const [uniqLibName] = await setup([ | ||
{ name: uniq('minimal-lib'), generator: 'minimal' }, | ||
]); | ||
|
||
expect(() => { | ||
runNxCommand(`deploy ${uniqLibName} --dry-run`); | ||
runNxCommand(`deploy ${uniqLibName.name} --dry-run`); | ||
}).not.toThrow(); | ||
}, 120000); | ||
}); |
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,21 +1,31 @@ | ||
import { initNgxDeployNPMProject, basicSetTestForLibs } from '../utils'; | ||
import { runNxCommand, uniq } from '@nx/plugin/testing'; | ||
import { setup } from '../utils'; | ||
|
||
describe('Publish', () => { | ||
initNgxDeployNPMProject(); | ||
it('should publish an Angular Lib', async () => { | ||
const [angularLib] = await setup([ | ||
{ | ||
name: uniq('angular-lib'), | ||
generator: '@nx/angular', | ||
extraOptions: '--style css', | ||
}, | ||
]); | ||
|
||
describe('Basic deploy test for Angular Libs', () => { | ||
const libName = 'angular-lib'; | ||
const nxPlugin = '@nx/angular'; | ||
expect(() => { | ||
runNxCommand(`deploy ${angularLib.name} --dry-run`); | ||
}).not.toThrow(); | ||
}, 120000); | ||
|
||
basicSetTestForLibs(libName, nxPlugin, { | ||
libGeneratorCommandOptions: '--style css --directory="libs"', | ||
}); | ||
}); | ||
it('should publish an Node Lib', async () => { | ||
const [angularLib] = await setup([ | ||
{ | ||
name: uniq('node-lib'), | ||
generator: '@nx/node', | ||
}, | ||
]); | ||
|
||
describe('Basic deploy test for Node Libs', () => { | ||
const libName = 'node-lib'; | ||
const nxPlugin = '@nx/node'; | ||
|
||
basicSetTestForLibs(libName, nxPlugin); | ||
}); | ||
expect(() => { | ||
runNxCommand(`deploy ${angularLib.name} --dry-run`); | ||
}).not.toThrow(); | ||
}, 120000); | ||
}); |
Oops, something went wrong.