@@ -5,8 +5,8 @@ export default function() {
5
5
const selection = document . selectedLayers . layers
6
6
const Settings = sketch . Settings
7
7
8
- const ciToken = Settings . documentSettingForKey ( document , 'ci-token' )
9
- const ciUrl = Settings . documentSettingForKey ( document , 'ci-url' )
8
+ let ciToken = Settings . settingForKey ( 'ci-token' )
9
+ let ciUrl = 'https://codingcorp.coding.net/api/cci/job/252169/trigger'
10
10
11
11
function postIcon ( iconCatalog , iconName , iconCode ) {
12
12
console . log ( iconCatalog )
@@ -47,7 +47,7 @@ export default function() {
47
47
)
48
48
}
49
49
50
- if ( ciToken ) {
50
+ function main ( ) {
51
51
let iconCatalog = [ ]
52
52
let iconName = [ ]
53
53
let iconCode = [ ]
@@ -61,8 +61,27 @@ export default function() {
61
61
iconCode . push ( sketchSVG . toString ( ) )
62
62
} )
63
63
postIcon ( JSON . stringify ( iconCatalog ) . toString ( ) , JSON . stringify ( iconName ) . toString ( ) , JSON . stringify ( iconCode ) . toString ( ) )
64
+ }
65
+
66
+ if ( ciToken ) {
67
+ main ( )
64
68
} else {
65
- console . log ( 'The ci-token setting not found in this document! Make sure your current docmuent is Coding-Icons Library.' )
66
- sketch . UI . alert ( '⛔️ Wrong File!' , 'The ci-token setting not found in this document! \nPlease make sure current docmuent is the Coding-Icons Library.' )
69
+ sketch . UI . getInputFromUser (
70
+ "第一次使用需填写 CI 触发令牌" ,
71
+ {
72
+ description : '访问此链接获取令牌 https://codingcorp.coding.net/p/Design-Center/wiki/1495' ,
73
+ initialValue : '在此输入' ,
74
+ } ,
75
+ ( err , value ) => {
76
+ if ( err ) {
77
+ sketch . UI . message ( 'Publish has been canceled.' )
78
+ return
79
+ }
80
+ Settings . setSettingForKey ( 'ci-token' , value )
81
+ ciToken = Settings . settingForKey ( 'ci-token' )
82
+ sketch . UI . message ( 'Publish start ...' )
83
+ main ( )
84
+ }
85
+ )
67
86
}
68
87
}
0 commit comments