diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..1aa8e894 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +node_modules/ +common/temp/ \ No newline at end of file diff --git a/common/config/rush/shrinkwrap.yaml b/common/config/rush/shrinkwrap.yaml index f8ebddea..d0af0d87 100644 --- a/common/config/rush/shrinkwrap.yaml +++ b/common/config/rush/shrinkwrap.yaml @@ -10,6 +10,7 @@ dependencies: '@babel/types': 7.3.2 '@rush-temp/create-just': 'file:projects/create-just.tgz' '@rush-temp/example-lib': 'file:projects/example-lib.tgz' + '@rush-temp/just-scenario-tests': 'file:projects/just-scenario-tests.tgz' '@rush-temp/just-scripts': 'file:projects/just-scripts.tgz' '@rush-temp/just-scripts-utils': 'file:projects/just-scripts-utils.tgz' '@rush-temp/just-stack-monorepo': 'file:projects/just-stack-monorepo.tgz' @@ -19,7 +20,6 @@ dependencies: '@rush-temp/just-task-docs': 'file:projects/just-task-docs.tgz' '@rush-temp/just-task-logger': 'file:projects/just-task-logger.tgz' '@rush-temp/just-task-scripts': 'file:projects/just-task-scripts.tgz' - '@types/fs-extra': 5.0.4 '@types/glob': 7.1.1 '@types/handlebars': 4.0.40 '@types/jest': 23.3.13 @@ -1438,6 +1438,12 @@ packages: dev: false resolution: integrity: sha512-DsknoBvD8s+RFfSGjmERJ7ZOP1HI0UZRA3FSI+Zakhrc/Gy26YQsLI+m5V5DHxroHRJqCDLKJp7Hixn8zyaF7g== + /@types/fs-extra/5.0.5: + dependencies: + '@types/node': 10.14.4 + dev: false + resolution: + integrity: sha512-w7iqhDH9mN8eLClQOYTkhdYUOSpp25eXxfc6VbFOGtzxW34JcvctH2bKjj4jD4++z4R5iO5D+pg48W2e03I65A== /@types/glob/7.1.1: dependencies: '@types/events': 3.0.0 @@ -1491,6 +1497,10 @@ packages: dev: false resolution: integrity: sha512-nMRqS+mL1TOnIJrL6LKJcNZPB8V3eTfRo9FQA2b5gDvrHurC8XbSA86KNe0dShlEL7ReWJv/OU9NL7Z0dnqWTg== + /@types/node/10.14.4: + dev: false + resolution: + integrity: sha512-DT25xX/YgyPKiHFOpNuANIQIVvYEwCWXgK2jYYwqgaMrYE6+tq+DtmMwlD3drl6DJbUwtlIDnn0d7tIn/EbXBg== /@types/prompts/1.2.0: dev: false resolution: @@ -11035,7 +11045,7 @@ packages: dev: false name: '@rush-temp/create-just' resolution: - integrity: sha512-1PnWy5a+9ktkfBKL3z+0CFof7CCvVaLFJN1tyFzOxwWEBe4rLogH1hEuIL2EzdQOez1bzOaRwEU8Vayd5mT1+Q== + integrity: sha512-VqPWxKXK5WJf7P1eyxQMhOEUXNiG6NvtGsWHJz1d2hlkasPumWCSP2FBB/VbkWmflRTC5aM1kTJyETP7CODKtQ== tarball: 'file:projects/create-just.tgz' version: 0.0.0 'file:projects/example-lib.tgz': @@ -11044,9 +11054,23 @@ packages: dev: false name: '@rush-temp/example-lib' resolution: - integrity: sha512-aQJYnOTM5mj+8jLG1RPV3nJE/8yEUQrEqDlUq/e5OaihtNl+2r0shTotynRcOe+RfsZ2UeIRHIIx/r54xnwHYw== + integrity: sha512-Z8ADj+DpjglEG4REQHlAoy6KevG1sADdXSDbru28DRIwd7U52mMk8V//pFdhWZuqWNPHRVRKfY+xQj4XWc85Ww== tarball: 'file:projects/example-lib.tgz' version: 0.0.0 + 'file:projects/just-scenario-tests.tgz': + dependencies: + '@types/fs-extra': 5.0.5 + '@types/jest': 23.3.14 + '@types/node': 10.12.26 + fs-extra: 7.0.1 + jest: 23.6.0 + ts-jest: /ts-jest/23.10.5/jest@23.6.0 + dev: false + name: '@rush-temp/just-scenario-tests' + resolution: + integrity: sha512-+jnl5KqgUuNsO6XxGjGq5Yg5Os2KYnKRFe4/sbB7L5VQ1CnY7AouYJAvFBihiHffEYagTZhe2lgt9hYyz2oDXg== + tarball: 'file:projects/just-scenario-tests.tgz' + version: 0.0.0 'file:projects/just-scripts-utils.tgz': dependencies: '@types/fs-extra': 5.0.4 @@ -11073,11 +11097,12 @@ packages: semver: 5.6.0 tar: 4.4.8 ts-jest: /ts-jest/23.10.5/jest@23.6.0 + typescript: 3.3.3 yargs: 12.0.5 dev: false name: '@rush-temp/just-scripts-utils' resolution: - integrity: sha512-//P/9UIZoMZ/jXrHOzliDpUC1b+u8lFvySOeWmmt5MW1EpDY9ODbC0BkVeBlIWtNafrElVuF38sudAbKpm3PvA== + integrity: sha512-UukcnRXYP2zdlan0iCN3PaMdbdXc6cEq/P754tohohMGKXCfiFHVpsxBgNhIPKPhdzy5JXyeoASCO8pHE9nOWg== tarball: 'file:projects/just-scripts-utils.tgz' version: 0.0.0 'file:projects/just-scripts.tgz': @@ -11100,12 +11125,12 @@ packages: ts-loader: /ts-loader/5.3.3/typescript@3.3.3 typescript: 3.3.3 webpack: 4.29.5 - webpack-cli: 3.2.1 + webpack-cli: /webpack-cli/3.2.1/webpack@4.29.5 webpack-merge: 4.2.1 dev: false name: '@rush-temp/just-scripts' resolution: - integrity: sha512-DYwcOzErchqXHKj7x0ZK0MjUEROS/HzpF9eSbuVJBQ5mhAoQAxe1DskeOsxkWrWt1JXmmUza0gpxKWSf5GXWlw== + integrity: sha512-GGkkXH5ycwPhNovTUsVpLqQu21Np5fSzkpvjsRe27GOZgjwGVxOLLMGUDUMwv2MhTYNv2749SjPuWEcTVF44uQ== tarball: 'file:projects/just-scripts.tgz' version: 0.0.0 'file:projects/just-stack-monorepo.tgz': @@ -11118,7 +11143,7 @@ packages: dev: false name: '@rush-temp/just-stack-monorepo' resolution: - integrity: sha512-uA3SznVlyblvLzdHQDt5hcb0iBd/GYQmSMXcINfIWPlTvbIrhY17nHfBNumYwzY/XC/7NUppz8IGmL3NrM+KRg== + integrity: sha512-jzm3De+zoiaJTUdlZ041oyFXQHQavcpqEERufKif8oXv73SWzYrDWfOueue83ffQcXAZxLEXvv0TAMO1LXaX5Q== tarball: 'file:projects/just-stack-monorepo.tgz' version: 0.0.0 'file:projects/just-stack-single-lib.tgz': @@ -11131,7 +11156,7 @@ packages: dev: false name: '@rush-temp/just-stack-single-lib' resolution: - integrity: sha512-o52aWVhjnvZ7DPHLeTSktxlAse3CzyX0Wf4bX5kRDR7ctqxNUkiN5O3pQ6P1aGyZmh3s0/UVdL2g+xYqYqKv7Q== + integrity: sha512-bzu0woy+3NSlaiK4w87vmPtQSUdevAPfyHFa4G3EOjUBZlcJuNWMRjyVd4as1AHUj0Jsa6fm2f5T5kCiDGJRFg== tarball: 'file:projects/just-stack-single-lib.tgz' version: 0.0.0 'file:projects/just-stack-uifabric.tgz': @@ -11144,7 +11169,7 @@ packages: dev: false name: '@rush-temp/just-stack-uifabric' resolution: - integrity: sha512-QnkhtPFAKaAHXC52n8ly65epIuvC/rslRdm6uQFv/dtV07tqt4l7TmaU3B8HP/iN9jvAdJ7fFZc5OcXGnJg2qw== + integrity: sha512-l0ng8Sbh1oW1ar2uz6fSPTy5kEylwYfzJwUYVCZnPaOM1ZEYU6j2LRUfBnZWnMu5fy4Ae6cKkAAdBMFMeue91Q== tarball: 'file:projects/just-stack-uifabric.tgz' version: 0.0.0 'file:projects/just-task-docs.tgz': @@ -11189,15 +11214,17 @@ packages: 'file:projects/just-task-scripts.tgz': dependencies: cpx: 1.5.0 + jest-cli: 23.6.0 dev: false name: '@rush-temp/just-task-scripts' resolution: - integrity: sha512-0VC9u8Mp+U6n07zRkj54o2oVf5AjiSpA+j0/NdIEoj0KphvZiQbu5hdY52QpdQT+j98oQZmPp+QuDzqe3gsWJQ== + integrity: sha512-BOBMIZJ4ShHPCveUC5w2WEPOW4Jr6fBsvxuFeXxdEo0iqlkJQgKUB/Ud/rQp7c4wJl3VCviZV+GzA//T6iFOhw== tarball: 'file:projects/just-task-scripts.tgz' version: 0.0.0 'file:projects/just-task.tgz': dependencies: '@types/jest': 23.3.13 + '@types/mock-fs': 3.6.30 '@types/node': 10.12.21 '@types/resolve': 0.0.8 '@types/undertaker': 1.2.0 @@ -11205,6 +11232,7 @@ packages: '@types/yargs': 12.0.1 chalk: 2.4.2 jest: 23.6.0 + mock-fs: 4.8.0 resolve: 1.10.0 ts-jest: /ts-jest/23.10.5/jest@23.6.0 typescript: 3.3.3 @@ -11214,7 +11242,7 @@ packages: dev: false name: '@rush-temp/just-task' resolution: - integrity: sha512-9X7le0kn6l/mMRzxJ2BxE4CwPp19DO64Z0kLaPFtY/OSJg28NgaPf7DlvPS+DSnkKkt3z4JLyGF1v6zx83e6vw== + integrity: sha512-UEstoANc3HzUoTmk2Y6Z503I9ch//tdCtSYywwHcl/P2ONVwlSZypY5bDo1MbmDYJnmzLUDgmFpPfWWo5CLN1A== tarball: 'file:projects/just-task.tgz' version: 0.0.0 registry: 'https://registry.npmjs.org/' @@ -11232,6 +11260,7 @@ specifiers: '@babel/types': ^7.1.2 '@rush-temp/create-just': 'file:./projects/create-just.tgz' '@rush-temp/example-lib': 'file:./projects/example-lib.tgz' + '@rush-temp/just-scenario-tests': 'file:./projects/just-scenario-tests.tgz' '@rush-temp/just-scripts': 'file:./projects/just-scripts.tgz' '@rush-temp/just-scripts-utils': 'file:./projects/just-scripts-utils.tgz' '@rush-temp/just-stack-monorepo': 'file:./projects/just-stack-monorepo.tgz' @@ -11241,7 +11270,6 @@ specifiers: '@rush-temp/just-task-docs': 'file:./projects/just-task-docs.tgz' '@rush-temp/just-task-logger': 'file:./projects/just-task-logger.tgz' '@rush-temp/just-task-scripts': 'file:./projects/just-task-scripts.tgz' - '@types/fs-extra': ^5.0.4 '@types/glob': ^7.1.1 '@types/handlebars': ^4.0.39 '@types/jest': ^23.3.13 diff --git a/package.json b/package.json index d293476c..99d6c633 100644 --- a/package.json +++ b/package.json @@ -6,10 +6,10 @@ "scripts": { "postinstall": "node ./common/scripts/install-run-rush.js install", "build": "node ./common/scripts/install-run-rush.js build", + "test": "node ./common/scripts/install-run-rush.js test", "build:docs": "node ./common/scripts/install-run-rush.js build -t just-task-docs", "postbuild": "node ./scripts/copyReadme.js", "start": "node ./scripts/watch.js", - "test": "node ./common/scripts/install-run-rush.js test", "deploy": "node ./common/scripts/install-run-rush.js build && node ./common/scripts/install-run-rush.js publish -a -p -b master" }, "keywords": [], diff --git a/packages/create-just/src/commands/initCommand.ts b/packages/create-just/src/commands/initCommand.ts index abb3c5be..04e750d0 100644 --- a/packages/create-just/src/commands/initCommand.ts +++ b/packages/create-just/src/commands/initCommand.ts @@ -19,10 +19,10 @@ function checkEmptyRepo(projectPath: string) { export async function initCommand(argv: yargs.Arguments) { // TODO: autosuggest just-stack-* packages from npmjs.org - if (!argv.type) { + if (!argv.stack) { let response = await prompts({ type: 'select', - name: 'type', + name: 'stack', message: 'What type of repo to create?', choices: [ { title: 'Basic library', value: 'just-stack-single-lib' }, @@ -30,7 +30,7 @@ export async function initCommand(argv: yargs.Arguments) { { title: 'Monorepo', value: 'just-stack-monorepo' } ] }); - argv.type = response.type; + argv.stack = response.stack; } let name: string = ''; @@ -57,7 +57,7 @@ export async function initCommand(argv: yargs.Arguments) { logger.info('Initializing the repo in the current directory'); - const templatePath = await downloadPackage(argv.type); + const templatePath = await downloadPackage(argv.stack); if (templatePath) { applyTemplate(templatePath, paths.projectPath, { name }); @@ -66,7 +66,7 @@ export async function initCommand(argv: yargs.Arguments) { execSync('git add .'); execSync('git commit -m "initial commit"'); - if (argv.type.includes('monorepo')) { + if (argv.stack.includes('monorepo')) { rushUpdate(paths.projectPath); } diff --git a/packages/just-scenario-tests/Dockerfile b/packages/just-scenario-tests/Dockerfile new file mode 100644 index 00000000..a3fc87cb --- /dev/null +++ b/packages/just-scenario-tests/Dockerfile @@ -0,0 +1,24 @@ +# Stage 1: puppeteer + +FROM node:10-alpine as puppeteer + +# Installs latest Chromium package. +RUN apk update && apk upgrade && \ + echo @edge http://nl.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories && \ + echo @edge http://nl.alpinelinux.org/alpine/edge/main >> /etc/apk/repositories && \ + apk add --no-cache \ + chromium@edge \ + harfbuzz@edge \ + nss@edge \ + git \ + && rm -rf /var/cache/* + +# Tell Puppeteer to skip installing Chrome. We'll be using the installed package. +ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true + +# Stage 2: Use puppeteer + +FROM puppeteer +RUN git config --global user.email "someexample@somedomainyeahsomething.com" && git config --global user.name "Your Name" +WORKDIR /app/packages/just-scenario-tests/ +CMD ["/usr/local/bin/npm", "run", "_dockerTest"] \ No newline at end of file diff --git a/packages/just-scenario-tests/jest.config.js b/packages/just-scenario-tests/jest.config.js new file mode 100644 index 00000000..d9a90c61 --- /dev/null +++ b/packages/just-scenario-tests/jest.config.js @@ -0,0 +1 @@ +module.exports = require('../../scripts/jest.config'); diff --git a/packages/just-scenario-tests/package.json b/packages/just-scenario-tests/package.json new file mode 100644 index 00000000..6d4726be --- /dev/null +++ b/packages/just-scenario-tests/package.json @@ -0,0 +1,28 @@ +{ + "name": "just-scenario-tests", + "version": "0.1.0", + "description": "", + "main": "index.js", + "scripts": { + "build": "docker build -t just-scenario-tests -f Dockerfile ../..", + "test": "docker run -v $(pwd)/../..:/app just-scenario-tests", + "_dockerTest": "jest --detectOpenHandles" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "@types/node": "^10.12.18", + "@types/jest": "^23.3.13", + "@types/fs-extra": "^5.0.5", + "create-just": ">=0.6.3", + "just-scripts": ">=0.10.1 <1.0.0", + "just-stack-monorepo": ">=0.6.11", + "just-stack-single-lib": ">=0.5.9", + "just-stack-uifabric": ">=0.7.11", + "just-scripts-utils": ">=0.6.1 <1.0.0", + "fs-extra": "^7.0.1", + "ts-jest": "^23.10.5", + "jest": "^23.6.0" + } +} diff --git a/packages/just-scenario-tests/src/__tests__/create-just.spec.ts b/packages/just-scenario-tests/src/__tests__/create-just.spec.ts new file mode 100644 index 00000000..3f3892ba --- /dev/null +++ b/packages/just-scenario-tests/src/__tests__/create-just.spec.ts @@ -0,0 +1,45 @@ +import fs from 'fs-extra'; +import path from 'path'; +import { spawnSync } from '../spawnSync'; +import { tmpPath } from '../tmpPath'; + +const toolsPath = path.join(__dirname, '../../node_modules'); + +describe('create-just', () => { + beforeEach(() => { + if (fs.pathExistsSync(tmpPath)) { + fs.removeSync(tmpPath); + } + fs.mkdirpSync(tmpPath); + }); + + it('can provision a monorepo', () => { + const results = spawnSync( + process.execPath, + [ + path.join(toolsPath, 'create-just/bin/create-just.js'), + '-s', + 'just-stack-monorepo', + 'monorepo' + ], + { cwd: tmpPath } + ); + + expect(results).toContain('All Set!'); + }); + + it('can provision a single lib', () => { + const results = spawnSync( + process.execPath, + [ + path.join(toolsPath, 'create-just/bin/create-just.js'), + '-s', + 'just-stack-single-lib', + 'singlelib' + ], + { cwd: tmpPath } + ); + + expect(results).toContain('All Set!'); + }); +}); diff --git a/packages/just-scenario-tests/src/spawnSync.ts b/packages/just-scenario-tests/src/spawnSync.ts new file mode 100644 index 00000000..c9750f9a --- /dev/null +++ b/packages/just-scenario-tests/src/spawnSync.ts @@ -0,0 +1,7 @@ +import cp, { SpawnSyncOptions } from 'child_process'; +import { tmpPath } from './tmpPath'; + +export function spawnSync(cmd: string, args: string[], options: SpawnSyncOptions) { + const results = cp.spawnSync(cmd, args, { ...options, cwd: tmpPath }); + return results.stdout.toString() + results.stderr.toString(); +} diff --git a/packages/just-scenario-tests/src/tmpPath.ts b/packages/just-scenario-tests/src/tmpPath.ts new file mode 100644 index 00000000..8aba6c1f --- /dev/null +++ b/packages/just-scenario-tests/src/tmpPath.ts @@ -0,0 +1,4 @@ +import path from 'path'; +import os from 'os'; +const ToolPrefix = 'just-scenario-tests'; +export const tmpPath = path.join(os.tmpdir(), ToolPrefix); diff --git a/packages/just-scenario-tests/tsconfig.json b/packages/just-scenario-tests/tsconfig.json new file mode 100644 index 00000000..34cbd8c6 --- /dev/null +++ b/packages/just-scenario-tests/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "target": "es2015", + "module": "commonjs", + "declaration": true, + "declarationMap": true, + "outDir": "lib", + "strict": true, + "strictBindCallApply": false, + "esModuleInterop": true + }, + "include": ["src"] +} diff --git a/packages/just-scripts-utils/package.json b/packages/just-scripts-utils/package.json index 7ec410d3..52f75bcd 100644 --- a/packages/just-scripts-utils/package.json +++ b/packages/just-scripts-utils/package.json @@ -43,6 +43,7 @@ "@types/yargs": "12.0.1", "jest": "^23.6.0", "mock-fs": "^4.8.0", - "ts-jest": "^23.10.5" + "ts-jest": "^23.10.5", + "typescript": "~3.3.3" } } diff --git a/packages/just-stack-monorepo/template/scripts/package.json.hbs b/packages/just-stack-monorepo/template/scripts/package.json.hbs index 6d41cc63..eb142693 100644 --- a/packages/just-stack-monorepo/template/scripts/package.json.hbs +++ b/packages/just-stack-monorepo/template/scripts/package.json.hbs @@ -14,16 +14,13 @@ "license": "MIT", "dependencies": { "just-task": ">=0.7.5 <1.0.0", - "just-scripts": "^0.7.0" + "just-scripts": "^0.10.0" }, "devDependencies": { "just-stack-single-lib": ">=0.1.0", "just-stack-uifabric": ">=0.1.0" }, "just": { - "stacks": [ - "just-stack-single-lib", - "just-stack-uifabric" - ] + "stacks": ["just-stack-single-lib", "just-stack-uifabric"] } } diff --git a/rush.json b/rush.json index 1d6145e6..9eaff3e0 100644 --- a/rush.json +++ b/rush.json @@ -7,7 +7,7 @@ "strictPeerDependencies": false }, - "nodeSupportedVersionRange": ">=8.9.4 <9.0.0 || >=10.9.0 <11.0.0", + "nodeSupportedVersionRange": ">=8.9.4 <9.0.0 || >=10.9.0 <12.0.0", "projectFolderMaxDepth": 3, @@ -119,6 +119,11 @@ "packageName": "just-task-scripts", "projectFolder": "scripts", "shouldPublish": false + }, + { + "packageName": "just-scenario-tests", + "projectFolder": "packages/just-scenario-tests", + "shouldPublish": false } // { // "packageName": "just-stack-web-lib", diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 00000000..fb57ccd1 --- /dev/null +++ b/yarn.lock @@ -0,0 +1,4 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + +