@@ -5,8 +5,8 @@ export default function() {
55 const selection = document . selectedLayers . layers
66 const Settings = sketch . Settings
77
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'
1010
1111 function postIcon ( iconCatalog , iconName , iconCode ) {
1212 console . log ( iconCatalog )
@@ -47,7 +47,7 @@ export default function() {
4747 )
4848 }
4949
50- if ( ciToken ) {
50+ function main ( ) {
5151 let iconCatalog = [ ]
5252 let iconName = [ ]
5353 let iconCode = [ ]
@@ -61,8 +61,27 @@ export default function() {
6161 iconCode . push ( sketchSVG . toString ( ) )
6262 } )
6363 postIcon ( JSON . stringify ( iconCatalog ) . toString ( ) , JSON . stringify ( iconName ) . toString ( ) , JSON . stringify ( iconCode ) . toString ( ) )
64+ }
65+
66+ if ( ciToken ) {
67+ main ( )
6468 } 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+ )
6786 }
6887}
0 commit comments