1
1
import { logging } from '@angular-devkit/core' ;
2
- import * as fse from 'fs-extra' ;
3
2
4
3
import { Schema } from '../deploy/schema' ;
5
4
const Heroku = require ( 'heroku-client' ) ;
5
+ var url = require ( 'url' ) ;
6
+ const fetch = require ( "node-fetch" ) ;
6
7
7
8
// TODO: add your deployment code here!
8
9
export async function run ( dir : string , options : Schema , logger : logging . LoggerApi ) {
@@ -14,14 +15,39 @@ export async function run(dir: string, options: Schema, logger: logging.LoggerAp
14
15
const result = await heroku . get ( '/apps' ) ;
15
16
const site = result . find ( ( app => app . name === 'ngx-deploy-demo' ) )
16
17
17
- const slugResult = await heroku . post ( `/apps/${ site . name } /slugs` , {
18
- body : {
19
- process_types : { "web" : "node-v0.10.20-linux-x64/bin/node index.js" }
20
- }
18
+ const slugResult = await heroku . post ( `/apps/${ site . name } /slugs` , {
19
+ body : {
20
+ process_types : { "web" : "node-v0.10.20-linux-x64/bin/node index.js" }
21
21
}
22
+ }
22
23
) ;
24
+
25
+ // const upload
23
26
// console.log(site);
24
- console . log ( slugResult . blob . url ) ;
27
+ console . log ( slugResult ) ;
28
+ const apiUrl = slugResult . blob . url . replace ( '%3D' , '=' ) ;
29
+ console . log ( apiUrl ) ;
30
+
31
+
32
+ const response = await fetch ( slugResult . blob . url , {
33
+ method : `${ slugResult . blob . method } ` , // or 'PUT'
34
+ // body: JSON.stringify(data), // data can be `string` or {object}!
35
+ body : '@E:\ngx-deploy-heroku\ngx-deploy-sample\ngx-deploy-sample-0.0.0.tgz' ,
36
+ headers : {
37
+ 'Content-Type' : ''
38
+ }
39
+ } ) ;
40
+ console . log ( response ) ;
41
+ console . log ( slugResult . id ) ;
42
+
43
+ const release = await heroku . post ( `/apps/${ site . name } /releases` , {
44
+ body : {
45
+ slug : `${ slugResult . id } `
46
+ }
47
+ } ) ;
48
+
49
+ console . log ( release ) ;
50
+
25
51
}
26
52
catch ( error ) {
27
53
logger . error ( '❌ An error occurred!' ) ;
0 commit comments