デプロイ際、このアプリで生成したJavaScriptおよびCSS以外のファイルが削除されない対応

This commit is contained in:
xiaozhe.ma
2024-09-13 14:29:38 +09:00
parent c2793698c5
commit db8d942eaf
2 changed files with 43 additions and 7 deletions

View File

@@ -381,23 +381,49 @@ def uploadkintonefiles(file,c:config.KINTONE_ENV):
headers={config.API_V1_AUTH_KEY:c.API_V1_AUTH_VALUE}
data ={'name':'file','filename':os.path.basename(file)}
url = f"{c.BASE_URL}/k/v1/file.json"
r = httpx.post(url,headers=headers,data=data,files=upload_files)
r = httpx.post(url,headers=headers,data=data,files=upload_files)
#{"name":data['filename'],'fileKey':r['fileKey']}
return r.json()
def updateappjscss(app,uploads,c:config.KINTONE_ENV):
dsjs = []
dscss = []
#mobile側
mbjs = []
mbcss = []
customize = getappcustomize(app, c)
current_js = customize['desktop'].get('js', [])
current_css = customize['desktop'].get('css', [])
current_mobile_js = customize['mobile'].get('js', [])
current_mobile_css = customize['mobile'].get('css', [])
current_js = [item for item in current_js if not (item.get('type') == 'URL' and item.get('url', '').endswith('alc_runtime.js'))]
for upload in uploads:
for key in upload:
filename = os.path.basename(key)
if key.endswith('.js'):
if (key.endswith('alc_runtime.js') and config.DEPLOY_MODE == "DEV"):
dsjs.append({'type':'URL','url':config.DEPLOY_JS_URL})
existing_js = next((item for item in current_js if item['file']['name'] == filename), None)
if existing_js:
existing_js['file']['fileKey'] = upload[key]
else:
dsjs.append({'type':'FILE','file':{'fileKey':upload[key]}})
if (key.endswith('alc_runtime.js') and config.DEPLOY_MODE == "DEV"):
dsjs.append({'type':'URL','url':config.DEPLOY_JS_URL})
else:
dsjs.append({'type':'FILE','file':{'fileKey':upload[key]}})
elif key.endswith('.css'):
dscss.append({'type':'FILE','file':{'fileKey':upload[key]}})
existing_css = next((item for item in current_css if item['file']['name'] == key), None)
if existing_css:
existing_css['file']['fileKey'] = upload[key]
else:
dscss.append({'type': 'FILE', 'file': {'fileKey': upload[key]}})
#現在のJSとCSSがdsjsに追加する
dsjs.extend(current_js)
dscss.extend(current_css)
mbjs.extend(current_mobile_js)
mbcss.extend(current_mobile_css)
ds ={'js':dsjs,'css':dscss}
mb ={'js':[],'css':[]}
mb ={'js':mbjs,'css':mbcss}
data = {'app':app,'scope':'ALL','desktop':ds,'mobile':mb}
headers={config.API_V1_AUTH_KEY:c.API_V1_AUTH_VALUE,"Content-Type": "application/json"}
url = f"{c.BASE_URL}{config.API_V1_STR}/preview/app/customize.json"
@@ -405,6 +431,15 @@ def updateappjscss(app,uploads,c:config.KINTONE_ENV):
r = httpx.put(url,headers=headers,data=json.dumps(data))
return r.json()
#kintone カスタマイズ情報
def getappcustomize(app,c:config.KINTONE_ENV):
headers={config.API_V1_AUTH_KEY:c.API_V1_AUTH_VALUE}
url = f"{c.BASE_URL}{config.API_V1_STR}/app/customize.json"
params = {"app":app}
r = httpx.get(url,headers=headers,params=params)
return r.json()
def getTempPath(filename):
scriptdir = Path(__file__).resolve().parent
rootdir = scriptdir.parent.parent.parent.parent
@@ -727,6 +762,7 @@ async def createjstokintone(request:Request,app:str,env:config.KINTONE_ENV = Dep
for file in files:
upload = uploadkintonefiles(file,env)
if upload.get('fileKey') != None:
print(upload)
jscs.append({ file :upload['fileKey']})
appjscs = updateappjscss(app,jscs,env)
if appjscs.get("revision") != None:

View File

@@ -66,7 +66,7 @@ export class ActionProcess{
result = await action.process(nextAction,this.event,this.context);
}
let nextInput = '';
//outputPoints一以上㝮場坈〝次㝮InputPoint戻り値を設定
//outputPoints一以上の場合、次のInputPoint戻り値を設定
if(nextAction.outputPoints && nextAction.outputPoints.length>1){
nextInput = result.result||'';
}