@seayoo-web/kms 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.js +1 -1
- package/dist/plugin.vite.js +1 -1
- package/dist/plugin.webpack.js +1 -1
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const pkg=require("../package.json"),needle=require("needle"),path=require("path"),fs=require("fs");async function syncTemplate({user:e,service:
|
|
1
|
+
const pkg=require("../package.json"),needle=require("needle"),path=require("path"),fs=require("fs");async function syncTemplate({user:e,service:t},s){if(!t)return!1;if(!e)throw"插件参数缺失,需要传递 user";if(/^https:\/\/([^.]*.)?kms\.seayoo\.(?:com|io)\/sync\/template\/[^/]+/i.test(t))throw"service 参数格式错误,请检查";const n=path.join(s,"index.html");if(!fs.existsSync(n))throw"index.html 没有找到";const r=fs.readFileSync(n).toString("utf-8");if(!r.includes("<script src=/")&&!r.includes("<link href=/"))throw"SPA 资源引用路径需要是以 / 开头的绝对路径";return new Promise(((s,n)=>{needle.post(t,{content:r},{headers:{"x-kms-user":e,"User-Agent":"kms agent/"+pkg.version}},(function(e){e?n(e):s(!0)}))}))}exports.syncTemplate=syncTemplate,exports.getTemplateListUrl=function(e){const t=e.match(/^(https:\/\/[^\/]+)\/.+\/([^/]+)$/);return t?`${t[1]}/tmpl/edit/${t[2]}`:null};
|
package/dist/plugin.vite.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const{syncTemplate:syncTemplate}=require("./core"),distCacheKey="_kms_dist",path=require("path");require("colors"),module.exports=function(e){return{name:"kmsAgent",generateBundle({dir:e}){let t=process.cwd();e&&(t=path.resolve(t,e)),this.cache.set("_kms_dist",t)},writeBundle(t,s){this.cache.get("_kms_dist");return syncTemplate({user:e.user,service:e.service}).then((function(e){e&&console.log("[KMS Agent]".bgGreen,"模板同步成功".green)}))}}};
|
|
1
|
+
const{syncTemplate:syncTemplate,getTemplateListUrl:getTemplateListUrl}=require("./core"),distCacheKey="_kms_dist",path=require("path");require("colors"),module.exports=function(e){return{name:"kmsAgent",generateBundle({dir:e}){let t=process.cwd();e&&(t=path.resolve(t,e)),this.cache.set("_kms_dist",t)},writeBundle(t,s){this.cache.get("_kms_dist");return syncTemplate({user:e.user,service:e.service}).then((function(e){e&&console.log("[KMS Agent]".bgGreen,"模板同步成功".green,getTemplateListUrl(syncOptions.service))}))}}};
|
package/dist/plugin.webpack.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const{syncTemplate:syncTemplate}=require("./core"),path=require("path");function syncKMSTemplate({user:e,service:t}){this.syncOptions={user:e,service:t}}require("colors"),syncKMSTemplate.prototype.apply=function(e){const t=this.syncOptions;e.hooks.done.tapAsync("kmsAgent",(function({compilation:e},n){const
|
|
1
|
+
const{syncTemplate:syncTemplate,getTemplateListUrl:getTemplateListUrl}=require("./core"),path=require("path");function syncKMSTemplate({user:e,service:t}){this.syncOptions={user:e,service:t}}function log(...e){setTimeout((()=>{console.log(...e)}))}require("colors"),syncKMSTemplate.prototype.apply=function(e){const t=this.syncOptions;e.hooks.done.tapAsync("kmsAgent",(function({compilation:e},n){const s=e.outputOptions.path;syncTemplate(t,s).then((e=>{e&&log("[KMS Agent]".bgGreen,"模板同步成功".green,getTemplateListUrl(t.service)),n()})).catch((e=>{log("[KMS Agent]".bgBrightRed,e.bgBrightRed),n()}))}))},module.exports=syncKMSTemplate;
|