Esri / solution.js

TypeScript wrappers running in Node.js and modern browsers for transferring ArcGIS Online items from one organization to another.
https://esri.github.io/solution.js/
Apache License 2.0
38 stars 12 forks source link

Ensure Solution.js can run in Node #309

Open dbouwman opened 4 years ago

dbouwman commented 4 years ago

Currently a number of tests are not run in node because of how Blob and File objects are utilized. This also means that the entire library can not be used in Node, which blocks the creation of an api that executes the Solution deployment process... which is a long-term goal of the Hub Team.

That said, rest-js and hub.js leverage patterns and external libraries to handle Blob's

Hub.js pulls in fetch-blob and abstracts out blob in a _which-blob helper as shown here: https://github.com/Esri/hub.js/blob/master/packages/common/src/resources/_which-blob/_which-blob.ts

We will need to look for a similar option for File - there is file-api, but it's not clear if that is designed for isomorphic libraries or not.

mpayson commented 4 years ago

(I believe related) I just tried running createSolution in Node (13.11.0) and get the following error. Looks like the uuidv4 library assumes a crypto global which isn't a global by default (separate module)

(node:22166) UnhandledPromiseRejectionWarning: ReferenceError: crypto is not defined
    at /Users/maxp8108/esridev/presentations/2020-epc-dev/demo-extend-arcgis/web-client/node_modules/@esri/solution-common/dist/node/libs/uuidv4.js:25:14
    at String.replace (<anonymous>)
    at Object.createPseudoGUID (/Users/maxp8108/esridev/presentations/2020-epc-dev/demo-extend-arcgis/web-client/node_modules/@esri/solution-common/dist/node/libs/uuidv4.js:22:23)
    at _getDeploymentProperties (/Users/maxp8108/esridev/presentations/2020-epc-dev/demo-extend-arcgis/web-client/node_modules/@esri/solution-creator/dist/node/creator.js:277:103)
    at /Users/maxp8108/esridev/presentations/2020-epc-dev/demo-extend-arcgis/web-client/node_modules/@esri/solution-creator/dist/node/creator.js:226:25
    at new Promise (<anonymous>)
    at _createSolutionItem (/Users/maxp8108/esridev/presentations/2020-epc-dev/demo-extend-arcgis/web-client/node_modules/@esri/solution-creator/dist/node/creator.js:217:12)
    at /Users/maxp8108/esridev/presentations/2020-epc-dev/demo-extend-arcgis/web-client/node_modules/@esri/solution-creator/dist/node/creator.js:197:9
    at new Promise (<anonymous>)
    at _createSolutionFromItemIds (/Users/maxp8108/esridev/presentations/2020-epc-dev/demo-extend-arcgis/web-client/node_modules/@esri/solution-creator/dist/node/creator.js:195:12)

Got around this by specifying the deploy.id.<id> tag, however FileReader API also causing issues in Node in blobToText