| 151 | } |
| 152 | |
| 153 | async execute() { |
| 154 | const startTime = Date.now(); |
| 155 | |
| 156 | await Promise.all([ |
| 157 | this.bundler.bundle(), |
| 158 | this.site ? this.site.init() : Promise.resolve(), |
| 159 | this.kv.init() |
| 160 | ]); |
| 161 | |
| 162 | logger.progress('Deploying worker...'); |
| 163 | |
| 164 | const zoneName = await deploy({ |
| 165 | name: this.args.name, |
| 166 | code: this.bundler.code, |
| 167 | accountId: this.accountId, |
| 168 | accountEmail: this.accountEmail, |
| 169 | zoneId: this.zoneId, |
| 170 | apiKey: this.apiKey, |
| 171 | purgeCache: this.args.purgeCache, |
| 172 | routePattern: this.args.route, |
| 173 | site: this.site, |
| 174 | kv: this.kv |
| 175 | }); |
| 176 | |
| 177 | const url = 'https://' + (this.args.route ? this.args.route : zoneName); |
| 178 | logger.success( |
| 179 | `Deployed worker to ${chalk.cyan.underline(url)}`, |
| 180 | Date.now() - startTime |
| 181 | ); |
| 182 | } |
| 183 | |
| 184 | dispose() { |
| 185 | this.bundler.dispose(); |