()
| 94 | } |
| 95 | |
| 96 | syncEnvVars() { |
| 97 | console.log(`Sync-ing for [${this.currentEnv}]...`); |
| 98 | |
| 99 | // ensure that required vars are set |
| 100 | let missingVars = []; |
| 101 | ALLOWED_VARS.forEach((varDict) => { |
| 102 | if (varDict.required && !this.v.get(varDict.name)) { |
| 103 | missingVars.push(varDict.name); |
| 104 | } |
| 105 | }); |
| 106 | if (missingVars.length > 0) { |
| 107 | console.error(`Missing required vars: ${missingVars.join(', ')}`); |
| 108 | process.exit(1); |
| 109 | } |
| 110 | // ensure that the project name is valid |
| 111 | if (!this.v.get('CLOUDFLARE_PROJECT_NAME').match(/^[a-zA-Z0-9-]+$/)) { |
| 112 | console.error(`Invalid project name: ${this.v.get('CLOUDFLARE_PROJECT_NAME')}`); |
| 113 | process.exit(1); |
| 114 | } |
| 115 | |
| 116 | |
| 117 | this.cmd.getDatabaseId((databaseId) => { |
| 118 | console.log('Database id (num of chars): ', databaseId.length) |
| 119 | const varsToAddOrUpdate = JSON.stringify({ |
| 120 | 'deployment_configs': { |
| 121 | ...this._getEnvVarsFromFilesJson(this.currentEnv, databaseId), |
| 122 | }, |
| 123 | }); |
| 124 | |
| 125 | this._updateEnvVars(varsToAddOrUpdate, (json) => { |
| 126 | console.log(`Successfully synced for [${this.currentEnv}]!`); |
| 127 | if (json.result && json.result.deployment_configs) { |
| 128 | console.log(json.result.deployment_configs[this.currentEnv].env_vars); |
| 129 | } else if (json) { |
| 130 | console.log(json); |
| 131 | } |
| 132 | }); |
| 133 | }); |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | const syncProjectConfig = new SyncProjectConfig(); |
no test coverage detected