From 223618d7cc87484b9a0f26052da711c5f2ef1e40 Mon Sep 17 00:00:00 2001 From: Alexander Harris Date: Sun, 5 Dec 2021 00:05:38 -0800 Subject: [PATCH] feat: add support for developing on windows --- package-lock.json | 221 ++++++++++++++++++ package.json | 13 +- packages/codegen-ui-react/package-lock.json | 2 - .../studio-template-renderer.test.ts | 3 +- packages/codegen-ui/package-lock.json | 2 - packages/test-generator/package-lock.json | 2 - scripts/integ-setup.bat | 24 ++ scripts/integ-setup.sh | 2 +- scripts/integ-templates.bat | 3 + scripts/integ-test.bat | 4 + 10 files changed, 265 insertions(+), 11 deletions(-) create mode 100644 scripts/integ-setup.bat create mode 100644 scripts/integ-templates.bat create mode 100644 scripts/integ-test.bat diff --git a/package-lock.json b/package-lock.json index 00416be4b..0eebbe742 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,7 @@ "@types/node": "^15.14.0", "@typescript-eslint/eslint-plugin": "^4.22.0", "@typescript-eslint/parser": "^4.7.0", + "copyfiles": "^2.4.1", "eslint": "^7.24.0", "eslint-config-airbnb-typescript": "^12.3.1", "eslint-config-prettier": "^8.2.0", @@ -29,6 +30,7 @@ "nodemon": "^2.0.14", "prettier": "2.3.2", "rimraf": "^3.0.2", + "run-script-os": "^1.1.6", "ts-jest": "^27.0.3", "ts-node": "^8.10.1", "typescript": "^4.3.5" @@ -4510,6 +4512,66 @@ "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", "dev": true }, + "node_modules/copyfiles": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/copyfiles/-/copyfiles-2.4.1.tgz", + "integrity": "sha512-fereAvAvxDrQDOXybk3Qu3dPbOoKoysFMWtkY3mv5BsL8//OSZVL5DCLYqgRfY5cWirgRzlC+WSrxp6Bo3eNZg==", + "dev": true, + "license": "MIT", + "dependencies": { + "glob": "^7.0.5", + "minimatch": "^3.0.3", + "mkdirp": "^1.0.4", + "noms": "0.0.0", + "through2": "^2.0.1", + "untildify": "^4.0.0", + "yargs": "^16.1.0" + }, + "bin": { + "copyfiles": "copyfiles", + "copyup": "copyfiles" + } + }, + "node_modules/copyfiles/node_modules/readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dev": true, + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/copyfiles/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, + "node_modules/copyfiles/node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, + "node_modules/copyfiles/node_modules/through2": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", + "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", + "dev": true, + "dependencies": { + "readable-stream": "~2.3.6", + "xtend": "~4.0.1" + } + }, "node_modules/core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", @@ -9761,6 +9823,40 @@ "node": ">=4" } }, + "node_modules/noms": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/noms/-/noms-0.0.0.tgz", + "integrity": "sha1-2o69nzr51nYJGbJ9nNyAkqczKFk=", + "dev": true, + "dependencies": { + "inherits": "^2.0.1", + "readable-stream": "~1.0.31" + } + }, + "node_modules/noms/node_modules/isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "node_modules/noms/node_modules/readable-stream": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "dev": true, + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "node_modules/noms/node_modules/string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + }, "node_modules/nopt": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.3.tgz", @@ -11526,6 +11622,17 @@ "queue-microtask": "^1.2.2" } }, + "node_modules/run-script-os": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/run-script-os/-/run-script-os-1.1.6.tgz", + "integrity": "sha512-ql6P2LzhBTTDfzKts+Qo4H94VUKpxKDFz6QxxwaUZN0mwvi7L3lpOI7BqPCq7lgDh3XLl0dpeXwfcVIitlrYrw==", + "dev": true, + "license": "MIT", + "bin": { + "run-os": "index.js", + "run-script-os": "index.js" + } + }, "node_modules/rxjs": { "version": "6.6.7", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz", @@ -12687,6 +12794,15 @@ "node": ">= 10.0.0" } }, + "node_modules/untildify": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/untildify/-/untildify-4.0.0.tgz", + "integrity": "sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/upath": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/upath/-/upath-2.0.1.tgz", @@ -16846,6 +16962,63 @@ } } }, + "copyfiles": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/copyfiles/-/copyfiles-2.4.1.tgz", + "integrity": "sha512-fereAvAvxDrQDOXybk3Qu3dPbOoKoysFMWtkY3mv5BsL8//OSZVL5DCLYqgRfY5cWirgRzlC+WSrxp6Bo3eNZg==", + "dev": true, + "requires": { + "glob": "^7.0.5", + "minimatch": "^3.0.3", + "mkdirp": "^1.0.4", + "noms": "0.0.0", + "through2": "^2.0.1", + "untildify": "^4.0.0", + "yargs": "^16.1.0" + }, + "dependencies": { + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "through2": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", + "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", + "dev": true, + "requires": { + "readable-stream": "~2.3.6", + "xtend": "~4.0.1" + } + } + } + }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", @@ -20897,6 +21070,42 @@ } } }, + "noms": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/noms/-/noms-0.0.0.tgz", + "integrity": "sha1-2o69nzr51nYJGbJ9nNyAkqczKFk=", + "dev": true, + "requires": { + "inherits": "^2.0.1", + "readable-stream": "~1.0.31" + }, + "dependencies": { + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "readable-stream": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + } + } + }, "nopt": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.3.tgz", @@ -22248,6 +22457,12 @@ "queue-microtask": "^1.2.2" } }, + "run-script-os": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/run-script-os/-/run-script-os-1.1.6.tgz", + "integrity": "sha512-ql6P2LzhBTTDfzKts+Qo4H94VUKpxKDFz6QxxwaUZN0mwvi7L3lpOI7BqPCq7lgDh3XLl0dpeXwfcVIitlrYrw==", + "dev": true + }, "rxjs": { "version": "6.6.7", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz", @@ -23118,6 +23333,12 @@ "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", "dev": true }, + "untildify": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/untildify/-/untildify-4.0.0.tgz", + "integrity": "sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw==", + "dev": true + }, "upath": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/upath/-/upath-2.0.1.tgz", diff --git a/package.json b/package.json index a8510e5ba..214040c93 100644 --- a/package.json +++ b/package.json @@ -20,10 +20,16 @@ "lint": "eslint . --ext .js,.jsx,.ts,.tsx", "lint:fix": "eslint . --ext .js,.jsx,.ts,.tsx --fix", "integ": "npm run integ:setup && npm run integ:test", - "integ:setup": "./scripts/integ-setup.sh", - "integ:templates": "./scripts/integ-templates.sh", + "integ:setup": "run-script-os", + "integ:setup:default": "./scripts/integ-setup.sh", + "integ:setup:win32": "scripts\\integ-setup.bat", + "integ:templates": "run-script-os", + "integ:templates:default": "./scripts/integ-templates.sh", + "integ:templates:win32": "scripts\\integ-templates.bat", "integ:templates:watch": "nodemon --watch packages/test-generator/integration-test-templates/ --watch packages/test-generator/lib -e tsx,ts,js,json --exec 'npm run integ:templates'", - "integ:test": "./scripts/integ-test.sh", + "integ:test": "run-script-os", + "integ:test:default": "./scripts/integ-test.sh", + "integ:test:win32": "scripts\\integ-test.bat", "integ:clean": "npx rimraf packages/integration-test", "iconset": "lerna run iconset" }, @@ -49,6 +55,7 @@ "nodemon": "^2.0.14", "prettier": "2.3.2", "rimraf": "^3.0.2", + "run-script-os": "^1.1.6", "ts-jest": "^27.0.3", "ts-node": "^8.10.1", "typescript": "^4.3.5" diff --git a/packages/codegen-ui-react/package-lock.json b/packages/codegen-ui-react/package-lock.json index 73068df28..05f795d3b 100644 --- a/packages/codegen-ui-react/package-lock.json +++ b/packages/codegen-ui-react/package-lock.json @@ -25191,7 +25191,6 @@ "dev": true, "peer": true, "requires": { - "@babel/core": "^7.14.0", "@babel/plugin-proposal-class-properties": "^7.0.0", "@babel/plugin-proposal-export-default-from": "^7.0.0", "@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0", @@ -25240,7 +25239,6 @@ "dev": true, "peer": true, "requires": { - "@babel/core": "^7.14.0", "babel-preset-fbjs": "^3.4.0", "hermes-parser": "0.4.7", "metro-babel-transformer": "0.66.2", diff --git a/packages/codegen-ui/lib/__tests__/studio-template-renderer.test.ts b/packages/codegen-ui/lib/__tests__/studio-template-renderer.test.ts index 2266a467a..79fa3114f 100644 --- a/packages/codegen-ui/lib/__tests__/studio-template-renderer.test.ts +++ b/packages/codegen-ui/lib/__tests__/studio-template-renderer.test.ts @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +import path from 'path'; import { MockOutputManager, MockTemplateRenderer } from './__utils__/mock-classes'; describe('StudioTemplateRenderer', () => { @@ -31,6 +32,6 @@ describe('StudioTemplateRenderer', () => { new MockTemplateRenderer(component, outputManager, {}).renderComponentToFilesystem(componentText)(fileName)( outputPath, ); - expect(outputManager.writeComponent).toHaveBeenCalledWith(componentText, `${outputPath}/${fileName}`); + expect(outputManager.writeComponent).toHaveBeenCalledWith(componentText, path.join(outputPath, fileName)); }); }); diff --git a/packages/codegen-ui/package-lock.json b/packages/codegen-ui/package-lock.json index 2ef805645..b6c784601 100644 --- a/packages/codegen-ui/package-lock.json +++ b/packages/codegen-ui/package-lock.json @@ -25153,7 +25153,6 @@ "dev": true, "peer": true, "requires": { - "@babel/core": "^7.14.0", "@babel/plugin-proposal-class-properties": "^7.0.0", "@babel/plugin-proposal-export-default-from": "^7.0.0", "@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0", @@ -25202,7 +25201,6 @@ "dev": true, "peer": true, "requires": { - "@babel/core": "^7.14.0", "babel-preset-fbjs": "^3.4.0", "hermes-parser": "0.4.7", "metro-babel-transformer": "0.66.2", diff --git a/packages/test-generator/package-lock.json b/packages/test-generator/package-lock.json index 1d744d9a2..294372f12 100644 --- a/packages/test-generator/package-lock.json +++ b/packages/test-generator/package-lock.json @@ -26687,7 +26687,6 @@ "dev": true, "peer": true, "requires": { - "@babel/core": "^7.14.0", "@babel/plugin-proposal-class-properties": "^7.0.0", "@babel/plugin-proposal-export-default-from": "^7.0.0", "@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0", @@ -26736,7 +26735,6 @@ "dev": true, "peer": true, "requires": { - "@babel/core": "^7.14.0", "babel-preset-fbjs": "^3.4.0", "hermes-parser": "0.4.7", "metro-babel-transformer": "0.66.2", diff --git a/scripts/integ-setup.bat b/scripts/integ-setup.bat new file mode 100644 index 000000000..b3fd721f6 --- /dev/null +++ b/scripts/integ-setup.bat @@ -0,0 +1,24 @@ +:: clean workspace and build +call npm run integ:clean +call npm run build + +:: create +chdir packages +call npx create-react-app integration-test --use-npm --template typescript +chdir .. + +:: add files +call npm run integ:templates + +:: install +call lerna bootstrap +call lerna add --scope integration-test aws-amplify +call lerna add --scope integration-test @aws-amplify/ui-react +call lerna add --scope integration-test @aws-amplify/datastore +call lerna add --scope integration-test @aws-amplify/codegen-ui +call lerna add --scope integration-test @aws-amplify/codegen-ui-react +call lerna add --scope integration-test @aws-amplify/codegen-ui-test-generator +call lerna add --no-ci --scope integration-test react-router-dom +call lerna add --no-ci --scope integration-test @types/react-router-dom +call lerna add --no-ci --dev --scope integration-test cypress +call lerna add --no-ci --dev --scope integration-test wait-on diff --git a/scripts/integ-setup.sh b/scripts/integ-setup.sh index 09869098e..c6c032dec 100755 --- a/scripts/integ-setup.sh +++ b/scripts/integ-setup.sh @@ -12,7 +12,7 @@ npm run integ:templates # install lerna bootstrap lerna add --scope integration-test aws-amplify -lerna add --scope integration-test @aws-amplify/ui-react@next +lerna add --scope integration-test @aws-amplify/ui-react lerna add --scope integration-test @aws-amplify/datastore lerna add --scope integration-test @aws-amplify/codegen-ui lerna add --scope integration-test @aws-amplify/codegen-ui-react diff --git a/scripts/integ-templates.bat b/scripts/integ-templates.bat new file mode 100644 index 000000000..13c8c42bd --- /dev/null +++ b/scripts/integ-templates.bat @@ -0,0 +1,3 @@ +call lerna run build --scope @aws-amplify/codegen-ui-test-generator +call robocopy packages\test-generator\integration-test-templates packages\integration-test /E +call node packages/test-generator/dist/generators/GenerateTestApp.js diff --git a/scripts/integ-test.bat b/scripts/integ-test.bat new file mode 100644 index 000000000..f329174e7 --- /dev/null +++ b/scripts/integ-test.bat @@ -0,0 +1,4 @@ +chdir packages\integration-test +start npm start +call npx --no-install wait-on http://localhost:3000 +call npx --no-install cypress run -C cypress.json