flexn-io / renative

πŸš€πŸš€πŸš€ Unified Development Platform for iOS, tvOS, Android, Android TV, Android Wear, Web, Tizen TV, Tizen Watch, Tizen Mobile, LG webOS, macOS/OSX, Windows, KaiOS, FirefoxOS Firefox TV platforms
https://renative.org
MIT License
1.81k stars 180 forks source link

RNV does not create encrypt destination folder #930

Closed pauliusguzas closed 1 month ago

pauliusguzas commented 1 year ago

Describe the bug When encrypting data on new project, rnv asks to define where encrypted data will be stored (default is ./secrets) but renative doesn’t create that folder and you need to create it manually to make encrypt work

To Reproduce

  1. Have rnv project ready which doesn't have encrypt configured
  2. Run npx rnv crypto encrypt
  3. RNV asks to define destination of encrypted data
  4. Click "enter" - default will be selected
  5. RNV shows error that ./secrets can't be found

Expected behavior RNV creates destination folder

Desktop (please complete the following information):

pauliusguzas commented 11 months ago

on 1.0.0-canary.4 rnv doesn't show error in the end of the logs that .secrets can't be found

pauliusguzas@MacBook-Pro-de-Flexn template-starter % rnv crypto encrypt

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                                                                              β”‚
β”‚        β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•—β–ˆβ–ˆβ•—   β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—       β”‚
β”‚        β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β•šβ•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β•β•       β”‚
β”‚        β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ•”β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—         β”‚
β”‚        β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•  β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•”β•β•β•         β”‚
β”‚        β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘ β•šβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘ β•šβ–ˆβ–ˆβ–ˆβ–ˆβ•”β• β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—       β”‚
β”‚        β•šβ•β•  β•šβ•β•β•šβ•β•β•β•β•β•β•β•šβ•β•  β•šβ•β•β•β•β•šβ•β•  β•šβ•β•   β•šβ•β•   β•šβ•β•  β•šβ•β•β•β•  β•šβ•β•β•β•β•β•β•       β”‚
β”‚                                                                              β”‚
β”‚        Version: 1.0.0-canary.4                                               β”‚
β”‚        https://renative.org                                                  β”‚
β”‚        πŸš€ Firing up!...                                                      β”‚
β”‚        $ rnv crypto encrypt                                                  β”‚
β”‚        Start Time: 10/13/2023, 11:28:46 AM                                   β”‚
β”‚                                                                              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

[ task ] registerEngine:engine-core[1]
[ task ] configureRuntimeDefaults[1] appId:undefined
[ task ] checkAndMigrateProject[1]
[ task ] loadPluginTemplates[1]
[ task ] _parsePluginTemplateDependencies[1] scope:root
[ task ] parseRenativeConfigs[1]
[ task ] getWorkspaceDirPath[1]
[ task ] _generatePlatformTemplatePaths[1]
[ task ] checkAndBootstrapIfRequired[1]
[ task ] loadIntegrations[1]
[ task ] loadEngines[1]
[ task ] loadEnginePluginDeps[1]
[ task ] loadEnginePackageDeps[1]
[ task ] findSuitableTask[1]
[ info ] Current Engine: engine-core path: undefined
[ task ] registerMissingPlatformEngines[1]
[ task ] registerEngine:engine-rn[1]
[ task ] registerEngine:engine-rn-tvos[1]
[ task ] registerEngine:engine-rn-next[1]
[ task ] registerEngine:engine-rn-web[1]
[ task ] registerEngine:engine-rn-electron[1]
[ task ] initializeTask[1] crypto encrypt
[ task ] => [crypto encrypt]
[ task ] [crypto encrypt] checkIfProjectAndNodeModulesExists[1]
[ hook ] [crypto encrypt] executePipe ('crypto:encrypt:before')
[ task ] [crypto encrypt] taskRnvCryptoEncrypt[1]
[ task ] => [crypto encrypt] => [project configure]
[ hook ] [project configure] executePipe ('project:configure:before')
[ task ] [project configure] taskRnvProjectConfigure[1]
[ task ] [project configure] checkAndMigrateProject[2]
[ task ] [project configure] loadPluginTemplates[2]
[ task ] [project configure] _parsePluginTemplateDependencies[2] scope:root
[ task ] [project configure] parseRenativeConfigs[2]
[ task ] [project configure] getWorkspaceDirPath[2]
[ task ] [project configure] _generatePlatformTemplatePaths[2]
[ task ] => [project configure] => [workspace configure]
[ task ] [workspace configure] taskRnvWorkspaceConfigure[1]
[ task ] <= [project configure] <= workspace configure
[ task ] [project configure] checkIfTemplateConfigured[1]
[ task ] => [project configure] => [install]
[ hook ] [install] executePipe ('install:before')
[ task ] [install] taskRnvInstall[1] requiresInstall:false:true
[ hook ] [install] executePipe ('install:after')
[ task ] <= [project configure] <= install
[ task ] [project configure] checkCrypto[1]
[ warn ] [project configure] This project uses encrypted files but you don't have them installed
[ task ] [project configure] configureRuntimeDefaults[2] appId:template
[ task ] [project configure] applyTemplate[1] undefined=>undefined
[ task ] [project configure] configureRuntimeDefaults[3] appId:template
[ task ] => [project configure] => [install]
[ hook ] [install] executePipe ('install:before')
[ task ] [install] taskRnvInstall[2] requiresInstall:false:true
[ hook ] [install] executePipe ('install:after')
[ task ] <= [project configure] <= install
[ task ] => [project configure] => [app configure]
[ hook ] [app configure] executePipe ('app:configure:before')
[ task ] [app configure] taskRnvAppConfigure[1]
[ task ] [app configure] listAppConfigsFoldersSync[1] ignoreHiddenConfigs:true
[ task ] [app configure] loadPluginTemplates[3]
[ task ] [app configure] _parsePluginTemplateDependencies[3] scope:root
[ task ] [app configure] parseRenativeConfigs[3]
[ task ] [app configure] getWorkspaceDirPath[3]
[ task ] [app configure] _generatePlatformTemplatePaths[3]
[ task ] [app configure] getWorkspaceDirPath[4]
[ task ] [app configure] generateLocalConfig[1] resetAppId:false
[ info ] [app configure] Current App Config: template
[ hook ] [app configure] executePipe ('app:configure:after')
[ task ] <= [project configure] <= app configure
[ task ] [project configure] versionCheck[1]
[ task ] [project configure] versionCheck:rnvRunner:1.0.0-canary.4,rnvProject:1.0.0-canary.4[1]
[ task ] [project configure] configureEngines[1]
[ task ] [project configure] resolvePluginDependants[1]
[ task ] [project configure] configurePlugins[1]
[ info ] [project configure] Missing dependency @react-native-community/cli-platform-ios v(11.3.7) in package.json. This is template. NO ACTION
[ task ] [project configure] configureRuntimeDefaults[4] appId:template
[ task ] [project configure] copyRuntimeAssets[1]
[ task ] [project configure] configureTemplateFiles[1]
[ task ] [project configure] checkAndCreateGitignore[1]
[ task ] [project configure] generateRuntimeConfig[1]
[ task ] [project configure] overrideTemplatePlugins[1]
[ task ] [project configure] parsePlugins[1]
[ task ] [project configure] parseFonts[1]
[ task ] [project configure] parsePlugins[2]
[ hook ] [project configure] executePipe ('project:configure:after')
[ task ] <= [crypto encrypt] <= project configure
[ info ] [crypto encrypt] It seems you are running encrypt for the first time. Directory /Users/pauliusguzas/.rnv/@rnv/template-starter does not exist yet.
RNV will create it for you, make sure you add whatever you want encrypted in it and then run the command again
? Once ready, Continue? Yes
? You haven't passed a key with --key or set an env variable named CRYPTO_RNV_RNV_TEMPLATE_STARTER for the encryption
key. Would you like to generate one? Yes
[ success ] [crypto encrypt] The files were encrypted with key NruKspk&BNrRQmC&L53S. Make sure you keep it safe! Pass it with --key on decryption or set it as following env variable:

export CRYPTO_RNV_RNV_TEMPLATE_STARTER="NruKspk&BNrRQmC&L53S"

Error: ENOENT: no such file or directory, open '/Users/pauliusguzas/Desktop/renative/renative/packages/template-starter/secrets/privateConfigs.enc'
    at Object.openSync (node:fs:601:3)
    at Object.writeFileSync (node:fs:2249:35)
    at fsWriteFileSync (/Users/pauliusguzas/Desktop/renative/renative/packages/core/src/system/fs.ts:20:8)
    at /Users/pauliusguzas/Desktop/renative/renative/packages/engine-core/src/tasks/task.rnv.crypto.encrypt.ts:161:24
    at step (/Users/pauliusguzas/Desktop/renative/renative/node_modules/tslib/tslib.js:195:27)
    at Object.next (/Users/pauliusguzas/Desktop/renative/renative/node_modules/tslib/tslib.js:176:57)
    at fulfilled (/Users/pauliusguzas/Desktop/renative/renative/node_modules/tslib/tslib.js:166:62) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/Users/pauliusguzas/Desktop/renative/renative/packages/template-starter/secrets/privateConfigs.enc'
}

 $ rnv crypto encrypt - Done! πŸš€
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  πŸš€  SUMMARY | 10/13/2023, 11:28:53 AM                                       β”‚
β”‚  $ rnv crypto encrypt                                                        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  ReNative Version: 1.0.0-canary.4                                            β”‚
β”‚  Project Name ($package.name): @rnv/template-starter                         β”‚
β”‚  Project Version ($package.version): 1.0.0-canary.4                          β”‚
β”‚  Workspace ($.workspaceID): rnv                                              β”‚
β”‚  Engine: engine-core                                                         β”‚
β”‚  App Config (-c): template                                                   β”‚
β”‚  Build Scheme (-s): debug                                                    β”‚
β”‚  Supported Platforms: ios, android, androidtv, firetv,                       β”‚
β”‚  androidwear, web, webtv, tizen, tvos, webos, macos, windows,                β”‚
β”‚  tizenwatch, tizenmobile, kaios, chromecast                                  β”‚
β”‚  Env Info: darwin | x64 | node v18.16.0                                      β”‚
β”‚  Executed Time: 0h:0m:6s:950ms                                               β”‚
β”‚                                                                              β”‚
β”‚ [ warn ] [project configure] This project uses encrypted files but you don't have them installed
β”‚ [ success ] [crypto encrypt] The files were encrypted with key NruKspk&BNrRQmC&L53S. Make sure you keep it safe! Pass it with --key on decryption or set it as following env variable:

export CRYPTO_RNV_RNV_TEMPLATE_STARTER="NruKspk&BNrRQmC&L53S"

β”‚                                                                              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
pauliusguzas@MacBook-Pro-de-Flexn template-starter %
pauliusguzas commented 10 months ago

In canary.8 noticed also that rnv doesn't create decrypt destination folder and contents, if user runs rnv crypto encrypt when there is no encrypted and decryped data this error appears:

[Error: ENOENT: no such file or directory, lstat '/Users/pauliusguzas/.rnv/@rnv/template-starter'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'lstat',
  path: '/Users/pauliusguzas/.rnv/@rnv/template-starter'
}

 $ rnv crypto encrypt - Done! πŸš€
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  πŸš€  SUMMARY | 11/21/2023, 9:55:34 AM                                        β”‚
β”‚  $ rnv crypto encrypt                                                        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  ReNative Version: 1.0.0-canary.8                                            β”‚
β”‚  Project Name ($package.name): @rnv/template-starter                         β”‚
β”‚  Project Version ($package.version): 1.0.0-canary.8                          β”‚
β”‚  Workspace ($.workspaceID): rnv                                              β”‚
β”‚  Engine: engine-core                                                         β”‚
β”‚  App Config (-c): template                                                   β”‚
β”‚  Build Scheme (-s): debug                                                    β”‚
β”‚  Supported Platforms: ios, android, androidtv, firetv,                       β”‚
β”‚  androidwear, web, webtv, tizen, tvos, webos, macos, windows,                β”‚
β”‚  tizenwatch, tizenmobile, kaios, chromecast                                  β”‚
β”‚  Master Template: @rnv/template-starter                                      β”‚
β”‚  Env Info: darwin | x64 | node v18.16.0                                      β”‚
β”‚  Executed Time: 0h:0m:2s:62ms                                                β”‚
β”‚                                                                              β”‚
β”‚ [ warn ] [project configure] This project uses encrypted files but you don't have them installed
β”‚ [ success ] [crypto encrypt] The files were encrypted with key FUi0F1lK^GqxXcm5IZly. Make sure you keep it safe! Pass it with --key on decryption or set it as following env variable:

export CRYPTO_RNV_RNV_TEMPLATE_STARTER="FUi0F1lK^GqxXcm5IZly"

β”‚ You are trying to run global rnv command in your current project.
β”‚ This might lead to unexpected behaviour.
β”‚ Run your rnv command with npx prefix:
β”‚ npx rnv crypto encrypt
β”‚                                                                              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
pauliusguzas@MBP-de-Flexn template-starter %
pauliusguzas commented 9 months ago

Same issue in 1.0.0-rc.3 as in main description, secrets folder isn't created, test on template-starter