zendesk / zendesk_app_migrator

CLI tool to assist in migrating v1 App Framework apps to v2
Other
10 stars 5 forks source link

Migrator.js breakage #50

Open thomasbalsloev opened 6 years ago

thomasbalsloev commented 6 years ago

Trying to run the migration (as root) I get a JS error from the migrator.js file:

thomas-b zendesk_widget # /home/tb/.rvm/gems/ruby-2.4.4@rails51/bin/zat migrate --replace-v1 The Zendesk App Migration Helper isn't installed yet. Would you like to try installing now? (y) /usr/lib/node_modules/zendesk_app_migrator/lib/migrator.js:16 Symbol.asyncIterator = ^ TypeError: Cannot assign to read only property 'asyncIterator' of function 'function Symbol() { [native code] }' at Object. (/usr/lib/node_modules/zendesk_app_migrator/lib/migrator.js:16:22) at Module._compile (internal/modules/cjs/loader.js:678:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:689:10) at Module.load (internal/modules/cjs/loader.js:589:32) at tryModuleLoad (internal/modules/cjs/loader.js:528:12) at Function.Module._load (internal/modules/cjs/loader.js:520:3) at Module.require (internal/modules/cjs/loader.js:626:17) at require (internal/modules/cjs/helpers.js:20:18) at Object. (/usr/lib/node_modules/zendesk_app_migrator/lib/index.js:7:18) at Module._compile (internal/modules/cjs/loader.js:678:30) Unable to install the Zendesk App Migration Helper Please follow the installation instructions at https://github.com/zendesk/zendesk_app_migrator before running this command again

Any clues as to why I get this exception?

My env: nodejs v10.1.0 git v1.9.1 Linux Mint 17.2 Rafaela Ruby 2.4.4

thomasbalsloev commented 6 years ago

So I got tired of waiting and tried to hack the code myself. It seems like a basic error which should be easily fixed.

Replacing this in the migrator.js file:

Symbol.asyncIterator =
    Symbol.asyncIterator || Symbol.for("Symbol.asyncIterator");

with:

if (!Symbol.asyncIterator) {
  Object.defineProperty(Symbol, 'asyncIterator', {
    value: Symbol.for('Symbol.asyncIterator'),
  })
}

enabled the migration to run. Only to die horribly later. Command line output when trying to migrate a valid v1 app (exists in Zendesk marketplace and has existed for a few years):

ruby-2.4.4@rails51 tb@thomas-b:~/zendesk/app_scaffold$ zat migrate --path=/home/tb/workspace/web/zendesk_widget/src/ --replace-v1
? May zendesk_app_migrator anonymously report usage statistics to improve the tool over time? (Y/n) (node:23862) ExperimentalWarning: The fs.promises API is experimental
? May zendesk_app_migrator anonymously report usage statistics to improve the tool over time? Yes
App will be migrated from: /home/tb/workspace/web/zendesk_widget/src
App will be migrated to: /home/tb/workspace/web/zendesk_widget/src/v2/
? Are you sure you want to replace v1 files? Yes
v1 App will be backed up to: /home/tb/workspace/web/zendesk_widget/src/v1/
No parser and no filepath given, using 'babylon' the parser now but this will throw an error in the future. Please specify a parser or a filepath so one can be inferred.
`{ "parser": "postcss" }` is deprecated. Prettier now treats it as `{ "parser": "css" }`.
 [====================[22=] 13/13 steps complete
Installing dependencies
npm WARN deprecated browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.

> phantomjs-prebuilt@2.1.16 install /home/tb/workspace/web/zendesk_widget/src/node_modules/phantomjs-prebuilt
> node install.js

(node:23922) ExperimentalWarning: The fs.promises API is experimental
Considering PhantomJS found at /usr/bin/phantomjs
Found PhantomJS at /usr/bin/phantomjs ...verifying
Writing location.js file
PhantomJS is already installed on PATH at /usr/bin/phantomjs

> node-sass@4.9.3 install /home/tb/workspace/web/zendesk_widget/src/node_modules/node-sass
> node scripts/install.js

Cached binary found at /home/tb/.npm/node-sass/4.9.3/linux-x64-64_binding.node

> uglifyjs-webpack-plugin@0.4.6 postinstall /home/tb/workspace/web/zendesk_widget/src/node_modules/uglifyjs-webpack-plugin
> node lib/post_install.js

> node-sass@4.9.3 postinstall /home/tb/workspace/web/zendesk_widget/src/node_modules/node-sass
> node scripts/build.js

Binary found at /home/tb/workspace/web/zendesk_widget/src/node_modules/node-sass/vendor/linux-x64-64/binding.node
Testing binary
Binary is fine
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

added 1019 packages in 14.134s
Building v2 app

> app_scaffold@0.1.0 build /home/tb/workspace/web/zendesk_widget/src
> webpack -p

Hash: fb498f61fdaaf69c9d0f
Version: webpack 3.12.0
Time: 1840ms
     Asset       Size  Chunks                    Chunk Names
   main.js     336 kB       0  [emitted]  [big]  app
  main.css    2.65 kB       0  [emitted]         app
index.html  745 bytes          [emitted]         
  [90] (webpack)/buildin/global.js 509 bytes {0} [built]
 [125] multi babel-polyfill ./src/javascripts/index.js ./src/stylesheets/app.scss 52 bytes {0} [built]
 [328] ./src/javascripts/index.js 994 bytes {0} [built] [failed] [1 error]
 [329] ./src/stylesheets/app.scss 41 bytes {0} [built]
 [330] ./node_modules/css-loader?sourceMap&root=/home/tb/workspace/web/zendesk_widget/src/dist/assets!./node_modules/sass-loader/lib/loader.js?sourceMap!./src/stylesheets/app.scss 8.01 kB [built]
    + 329 hidden modules

ERROR in ./src/javascripts/index.js
Module build failed: Error: No ESLint configuration found.
    at Config.getLocalConfigHierarchy (/home/tb/workspace/web/zendesk_widget/src/node_modules/eslint/lib/config.js:255:39)
    at Config.getConfigHierarchy (/home/tb/workspace/web/zendesk_widget/src/node_modules/eslint/lib/config.js:179:43)
    at Config.getConfigVector (/home/tb/workspace/web/zendesk_widget/src/node_modules/eslint/lib/config.js:286:21)
    at Config.getConfig (/home/tb/workspace/web/zendesk_widget/src/node_modules/eslint/lib/config.js:329:29)
    at processText (/home/tb/workspace/web/zendesk_widget/src/node_modules/eslint/lib/cli-engine.js:163:33)
    at CLIEngine.executeOnText (/home/tb/workspace/web/zendesk_widget/src/node_modules/eslint/lib/cli-engine.js:620:17)
    at lint (/home/tb/workspace/web/zendesk_widget/src/node_modules/eslint-loader/index.js:218:17)
    at Object.module.exports (/home/tb/workspace/web/zendesk_widget/src/node_modules/eslint-loader/index.js:213:21)
 @ multi babel-polyfill ./src/javascripts/index.js ./src/stylesheets/app.scss
Child html-webpack-plugin for "index.html":
     1 asset
       [4] ./node_modules/handlebars-loader!./lib/templates/layout.hdbs 2.25 kB {0} [built]
        + 7 hidden modules
Child extract-text-webpack-plugin node_modules/extract-text-webpack-plugin/dist node_modules/css-loader/index.js?sourceMap&root=/home/tb/workspace/web/zendesk_widget/src/dist/assets!node_modules/sass-loader/lib/loader.js?sourceMap!src/stylesheets/app.scss:
       [0] ./node_modules/css-loader?sourceMap&root=/home/tb/workspace/web/zendesk_widget/src/dist/assets!./node_modules/sass-loader/lib/loader.js?sourceMap!./src/stylesheets/app.scss 8.01 kB {0} [built]
        + 1 hidden module
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! app_scaffold@0.1.0 build: `webpack -p`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the app_scaffold@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/tb/.npm/_logs/2018-09-04T08_19_32_401Z-debug.log
undefined
 [====================[22=] 13/13 steps completeError: Promise rejected with value: 'npm ERR! code ELIFECYCLE\nnpm ERR! errno 2\nnpm ERR! app_scaffold@0.1.0 build: `webpack -p`\nnpm ERR! Exit status 2\nnpm ERR! \nnpm ERR! Failed at the app_scaffold@0.1.0 build script.\nnpm ERR! This is probably not a problem with npm. There is likely additional logging output above.\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR!     /home/tb/.npm/_logs/2018-09-04T08_19_32_401Z-debug.log\n'
    at /usr/lib/node_modules/zendesk_app_migrator/node_modules/loud-rejection/index.js:27:12
    at Array.forEach (<anonymous>)
    at EventEmitter.<anonymous> (/usr/lib/node_modules/zendesk_app_migrator/node_modules/loud-rejection/index.js:23:24)
    at EventEmitter.emit (events.js:182:13)
    at emit (/usr/lib/node_modules/zendesk_app_migrator/node_modules/signal-exit/index.js:77:11)
    at processEmit [as emit] (/usr/lib/node_modules/zendesk_app_migrator/node_modules/signal-exit/index.js:150:5)

Content from above log file ("/home/tb/.npm/_logs/2018-09-04T08_19_32_401Z-debug.log"):

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'build' ]
2 info using npm@5.6.0
3 info using node@v10.1.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle app_scaffold@0.1.0~prebuild: app_scaffold@0.1.0
6 info lifecycle app_scaffold@0.1.0~build: app_scaffold@0.1.0
7 verbose lifecycle app_scaffold@0.1.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle app_scaffold@0.1.0~build: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/tb/workspace/web/zendesk_widget/src/node_modules/.bin:/home/tb/google-cloud-sdk/bin:/home/tb/perl5/bin:/home/tb/.rvm/gems/ruby-2.4.4@rails51/bin:/home/tb/.rvm/gems/ruby-2.4.4@global/bin:/home/tb/.rvm/rubies/ruby-2.4.4/bin:/usr/bin/mongodb:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/home/tb/.rvm/bin:/home/tb/.rvm/bin
9 verbose lifecycle app_scaffold@0.1.0~build: CWD: /home/tb/workspace/web/zendesk_widget/src
10 silly lifecycle app_scaffold@0.1.0~build: Args: [ '-c', 'webpack -p' ]
11 silly lifecycle app_scaffold@0.1.0~build: Returned: code: 2  signal: null
12 info lifecycle app_scaffold@0.1.0~build: Failed to exec build script
13 verbose stack Error: app_scaffold@0.1.0 build: `webpack -p`
13 verbose stack Exit status 2
13 verbose stack     at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16)
13 verbose stack     at EventEmitter.emit (events.js:182:13)
13 verbose stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:182:13)
13 verbose stack     at maybeClose (internal/child_process.js:957:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:246:5)
14 verbose pkgid app_scaffold@0.1.0
15 verbose cwd /home/tb/workspace/web/zendesk_widget/src
16 verbose Linux 4.4.0-119-generic
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "run" "build"
18 verbose node v10.1.0
19 verbose npm  v5.6.0
20 error code ELIFECYCLE
21 error errno 2
22 error app_scaffold@0.1.0 build: `webpack -p`
22 error Exit status 2
23 error Failed at the app_scaffold@0.1.0 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 2, true ]

Any clues to the reason for this failure?

Best regards, Thomas Balsløv.

Romboter commented 5 years ago

I used your if above but also modified the migrate.ts

Replaced (Symbol as any).asyncIterator = Symbol.asyncIterator || Symbol.for("Symbol.asyncIterator");

With if (typeof (Symbol as any).asyncIterator === 'undefined') { (Symbol as any).asyncIterator = Symbol.asyncIterator || Symbol('asyncIterator'); }

There looks to be something up around here, https://github.com/mimega/zendesk_app_migrator/blob/master/src/plugins/sync_to_async.ts#L265 I wrapped the whole section in an if if (undefined !== exp.node.arguments && exp.node.arguments.length) { Lines 265 to 366 }else{ console.log('FAIL!') }

I also replaced the app_scaffold folder with the latest from here, https://github.com/zendesk/app_scaffold

After that the migration completed, though the code it pumped into app.js is useless.

thomasbalsloev commented 5 years ago

@Romboter

Yep, the migration for me was also pretty useless. I spent many hours manually making the changes required, but I now have a working published v2 app. It seems it is better not to waste hours on trying to get the migration up and running and just do the conversion by hand (using the app_scaffold as a start template).