expo / turtle

Standalone app builder service
MIT License
385 stars 29 forks source link

Couldn't find app.json when using dynamic app.config.js #236

Closed jseed closed 4 years ago

jseed commented 4 years ago

I have switched my project to use app.config.js (as described in the expo documentation) to provide a dynamic configuration for individual environments.

Since making this change, when I try to build my project using turtle-cli, I receive the following error:

Failed to build standalone app
  err: Error: Couldn't find app.json.
      at Object.loadAppJSON (/Users/jon/.nvm/versions/node/v12.16.1/lib/node_modules/turtle-cli/src/bin/utils/project.ts:14:11)
      at /Users/jon/.nvm/versions/node/v12.16.1/lib/node_modules/turtle-cli/src/bin/utils/builder.ts:77:23
      at Command.<anonymous> (/Users/jon/.nvm/versions/node/v12.16.1/lib/node_modules/turtle-cli/src/bin/index.ts:23:12)
  platform: "ios"

I am able to work around this using a helper script to generate the config before I build, but in the long term it would be nice to have this supported out of the box.

manoelcampos commented 4 years ago

I pass -c app.config.js to turtle command but then I get:

Failed to build standalone app
  err: app.config.js:2
  export default {
  ^^^^^^

  SyntaxError: Cannot use import statement outside a module
      at wrapSafe (internal/modules/cjs/loader.js:1116:16)
      at Module._compile (internal/modules/cjs/loader.js:1164:27)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
      at Module.load (internal/modules/cjs/loader.js:1049:32)
      at Function.Module._load (internal/modules/cjs/loader.js:937:14)
      at Module.require (internal/modules/cjs/loader.js:1089:19)
      at require (internal/modules/cjs/helpers.js:73:18)
      at Object.loadAppJSON (/Users/manoelcampos/.config/yarn/global/node_modules/turtle-cli/src/bin/utils/project.ts:16:12)
      at /Users/manoelcampos/.config/yarn/global/node_modules/turtle-cli/src/bin/utils/builder.ts:77:23
      at Command.<anonymous> (/Users/manoelcampos/.config/yarn/global/node_modules/turtle-cli/src/bin/index.ts:23:12)
  platform: "android"

And the content of my app.config.js is just an ES6 module:

export default {
    name: "MyApp",
    slug: "MyApp",
    ...
}
manoelcampos commented 4 years ago

If I use the regular node modules syntax:

module.exports = {  
    name: "MyApp",
    slug: "MyApp",
    ...
}

I get a turtle error:

turtle[93076] ERROR: Failed to build standalone app
  err: TypeError: Cannot read property 'nodeModulesPath' of undefined
      at Object.projectHasModule (/Users/manoelcampos/.config/yarn/global/node_modules/@expo/config/src/Modules.ts:21:23)
      at Object.getExpoSDKVersion (/Users/manoelcampos/.config/yarn/global/node_modules/@expo/config/src/Project.ts:13:27)
      at getExpoSDKVersionSafely (/Users/manoelcampos/.config/yarn/global/node_modules/turtle-cli/src/bin/utils/builder.ts:102:12)
      at /Users/manoelcampos/.config/yarn/global/node_modules/turtle-cli/src/bin/utils/builder.ts:78:26
      at Command.<anonymous> (/Users/manoelcampos/.config/yarn/global/node_modules/turtle-cli/src/bin/index.ts:23:12)
  platform: "android"
wkozyra95 commented 4 years ago

it should work with latest turtle-cli