mirror of
https://github.com/antos-rde/antosdk-apps.git
synced 2024-12-26 12:18:21 +01:00
add support automatic locale generation to SDK
This commit is contained in:
parent
5c54bf2cdc
commit
d4bbb11b0b
@ -1,15 +1,5 @@
|
|||||||
# libantosdk
|
# libantosdk
|
||||||
This is an example project, generated by AntOS Development Kit
|
AntOSDK: development API for AntOS based applications/projects
|
||||||
|
|
||||||
## Howto
|
## Change logs
|
||||||
Use the CodePad command palette to access to the SDK functionalities:
|
- 0.0.4: support automatic locale generation
|
||||||
|
|
||||||
1. Create new project
|
|
||||||
2. Init the project from the current folder located in side bar
|
|
||||||
3. Build and run the project
|
|
||||||
4. Release the project in zip package
|
|
||||||
|
|
||||||
## Set up build target
|
|
||||||
|
|
||||||
Open the `project.json` file from the current project tree and add/remove
|
|
||||||
build target entries. Save the file
|
|
@ -8,6 +8,20 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"locale": {
|
||||||
|
"require": ["locale"],
|
||||||
|
"jobs": [
|
||||||
|
{
|
||||||
|
"name":"locale-gen",
|
||||||
|
"data": {
|
||||||
|
"src": "",
|
||||||
|
"exclude": ["build/debug/", "core/", "ts/test\\.ts", "scheme\\.html"],
|
||||||
|
"locale": "en_GB",
|
||||||
|
"dest": "package.json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"build": {
|
"build": {
|
||||||
"require": ["ts"],
|
"require": ["ts"],
|
||||||
"jobs":[
|
"jobs":[
|
||||||
|
@ -1,15 +1,5 @@
|
|||||||
# libantosdk
|
# libantosdk
|
||||||
This is an example project, generated by AntOS Development Kit
|
AntOSDK: development API for AntOS based applications/projects
|
||||||
|
|
||||||
## Howto
|
## Change logs
|
||||||
Use the CodePad command palette to access to the SDK functionalities:
|
- 0.0.4: support automatic locale generation
|
||||||
|
|
||||||
1. Create new project
|
|
||||||
2. Init the project from the current folder located in side bar
|
|
||||||
3. Build and run the project
|
|
||||||
4. Release the project in zip package
|
|
||||||
|
|
||||||
## Set up build target
|
|
||||||
|
|
||||||
Open the `project.json` file from the current project tree and add/remove
|
|
||||||
build target entries. Save the file
|
|
@ -1 +1 @@
|
|||||||
var OS;!function(e){let t;!function(t){class r{constructor(t){this.worker=new Worker(t.asFileHandle().getlink()),this.jobs={},this.worker.onmessage=e=>{let t=e.data,r=this.jobs[t.id];r?"log"===t.type?r.logger&&(t.error?r.logger.error(t.result):r.logger.info(t.result)):(r.callback(t),delete this.jobs[t.id]):console.log("Unable to identify result of job",t.id,t)};const r={};for(const t in e.setting.system.packages){const o=e.setting.system.packages[t];r[t]={path:o.path,name:o.pkgname}}this.submit("sdk-setup",{REST:e.API.REST,pkgs:r})}newJobID(){return"job_"+Math.random().toString(36).replace(".","")}exectue_job(e,t,r,o,s){const n=this.newJobID(),i={id:n,cmd:e,data:t,root:r};this.jobs[n]={callback:o,logger:s},this.worker.postMessage(i)}submit(e,t,r,o){return new Promise((s,n)=>{this.exectue_job(e,t,r,e=>{if(e.error)return n(e.error);s(e.result)},o)})}terminate(){this.worker.terminate()}}class o{constructor(e,t){this.root=t,this.logger=e,o.worker||(o.worker=new r("pkg://libantosdk/core/worker.js"))}require(e){return this.run("sdk-import",e.map(e=>e+".worker.js"))}compile(e,t){return new Promise(async(r,o)=>{try{await this.require([e]),r(await this.run(e+"-compile",t))}catch(e){o(__e(e))}})}run(t,r){return"sdk-run-app"===t?new Promise(async(t,o)=>{try{let o=r;1==o.split("://").length&&(o=`${this.root}/${r}`);const s=await(o+"/package.json").asFileHandle().read("json");return s.text=s.name,s.path=o,s.filename=s.pkgname,s.type="app",s.mime="antos/app",s.icon&&(s.icon=`${s.path}/${s.icon}`),s.iconclass||s.icon||(s.iconclass="fa fa-adn"),this.logger.info(__("Installing...")),e.setting.system.packages[s.pkgname]=s,s.app?(this.logger.info(__("Running {0}...",s.app)),e.GUI.forceLaunch(s.app,[])):this.logger.error(__("{0} is not an application",s.pkgname)),t(void 0)}catch(e){o(e)}}):o.worker.submit(t,r,this.root,this.logger)}batch(e,t){return t.root&&(this.root=t.root),new Promise(async(r,o)=>{try{t.targets||o("No target found");for(const r of e){const e=t.targets[r];if(!e)return o(__("No target: "+r));if(e.depend&&await this.batch(e.depend,t),e.require&&await this.require(e.require),this.logger&&this.logger.info(__(`### RUNNING STAGE: ${r}###`).__()),e.jobs)for(const t of e.jobs)await this.run(t.name,t.data)}r(void 0)}catch(e){o(e)}})}}let s;t.AntOSDKBuilder=o,function(e){class t extends e.RemoteFileHandle{constructor(e){super(e);const t="pkg://libantosdk/"+this.genealogy.join("/");this.setPath(t.asFileHandle().path)}}e.SDKFileHandle=t,e.register("^sdk$",t)}(s=t.VFS||(t.VFS={}))}(t=e.API||(e.API={}))}(OS||(OS={}));
|
var OS;!function(e){let t;!function(t){class r{constructor(t){this.worker=new Worker(t.asFileHandle().getlink()),this.jobs={},this.worker.onmessage=e=>{let t=e.data,r=this.jobs[t.id];r?"log"===t.type?r.logger&&(t.error?r.logger.error(t.result):r.logger.info(t.result)):(r.callback(t),delete this.jobs[t.id]):console.log("Unable to identify result of job",t.id,t)};const r={};for(const t in e.setting.system.packages){const o=e.setting.system.packages[t];r[t]={path:o.path,name:o.pkgname}}this.submit("sdk-setup",{REST:e.API.REST,pkgs:r})}newJobID(){return"job_"+Math.random().toString(36).replace(".","")}exectue_job(e,t,r,o,s){const n=this.newJobID(),i={id:n,cmd:e,data:t,root:r};this.jobs[n]={callback:o,logger:s},this.worker.postMessage(i)}submit(e,t,r,o){return new Promise((s,n)=>{this.exectue_job(e,t,r,e=>{if(e.error)return n(e.error);s(e.result)},o)})}terminate(){this.worker.terminate()}}class o{constructor(e,t){this.root=t,this.logger=e,o.worker||(o.worker=new r("pkg://libantosdk/core/worker.js"))}require(e){return this.run("sdk-import",e.map(e=>e+".worker.js"))}compile(e,t){return new Promise(async(r,o)=>{try{await this.require([e]),r(await this.run(e+"-compile",t))}catch(e){o(__e(e))}})}run(t,r){return"sdk-run-app"===t?new Promise(async(t,o)=>{try{let o=r;1==o.split("://").length&&(o=`${this.root}/${r}`);const s=await(o+"/package.json").asFileHandle().read("json");return s.text=s.name,s.path=o,s.filename=s.pkgname,s.type="app",s.mime="antos/app",s.icon&&(s.icon=`${s.path}/${s.icon}`),s.iconclass||s.icon||(s.iconclass="fa fa-adn"),this.logger.info(__("Installing...")),e.setting.system.packages[s.pkgname]=s,s.app?(this.logger.info(__("Running {0}...",s.app)),e.GUI.forceLaunch(s.app,[])):this.logger.error(__("{0} is not an application",s.pkgname)),t(void 0)}catch(e){o(e)}}):o.worker.submit(t,r,this.root,this.logger)}batch(e,t){return t.root&&(this.root=t.root),new Promise(async(r,o)=>{try{t.targets||o("No target found");for(const r of e){const e=t.targets[r];if(!e)return o(__("No target: {0}",r));if(e.depend&&await this.batch(e.depend,t),e.require&&await this.require(e.require),this.logger&&this.logger.info(__("### RUNNING STAGE: {0}###",r).__()),e.jobs)for(const t of e.jobs)await this.run(t.name,t.data)}r(void 0)}catch(e){o(e)}})}}let s;t.AntOSDKBuilder=o,function(e){class t extends e.RemoteFileHandle{constructor(e){super(e);const t="pkg://libantosdk/"+this.genealogy.join("/");this.setPath(t.asFileHandle().path)}}e.SDKFileHandle=t,e.register("^sdk$",t)}(s=t.VFS||(t.VFS={}))}(t=e.API||(e.API={}))}(OS||(OS={}));
|
@ -1,15 +1,25 @@
|
|||||||
{
|
{
|
||||||
"pkgname": "libantosdk",
|
"pkgname": "libantosdk",
|
||||||
"name":"AntOSDK",
|
"name": "AntOSDK",
|
||||||
"description":"AntOS Software Development Kit",
|
"description": "AntOS Software Development Kit",
|
||||||
"info":{
|
"info": {
|
||||||
"author": "Xuan Sang LE",
|
"author": "Xuan Sang LE",
|
||||||
"email": "mrsang@iohub.dev"
|
"email": "mrsang@iohub.dev"
|
||||||
},
|
},
|
||||||
"version":"0.0.3-a",
|
"version": "0.0.4-a",
|
||||||
"category":"Other",
|
"category": "Other",
|
||||||
"iconclass":"fa fa-cog",
|
"iconclass": "fa fa-cog",
|
||||||
"mimes":["none"],
|
"mimes": [
|
||||||
"dependencies":[],
|
"none"
|
||||||
"locale": {}
|
],
|
||||||
|
"dependencies": [],
|
||||||
|
"locale": {
|
||||||
|
"en_GB": {
|
||||||
|
"Installing...": "Installing...",
|
||||||
|
"Running {0}...": "Running {0}...",
|
||||||
|
"{0} is not an application": "{0} is not an application",
|
||||||
|
"No target: {0}": "No target: {0}",
|
||||||
|
"### RUNNING STAGE: {0}###": "### RUNNING STAGE: {0}###"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Binary file not shown.
@ -1,15 +1,25 @@
|
|||||||
{
|
{
|
||||||
"pkgname": "libantosdk",
|
"pkgname": "libantosdk",
|
||||||
"name":"AntOSDK",
|
"name": "AntOSDK",
|
||||||
"description":"AntOS Software Development Kit",
|
"description": "AntOS Software Development Kit",
|
||||||
"info":{
|
"info": {
|
||||||
"author": "Xuan Sang LE",
|
"author": "Xuan Sang LE",
|
||||||
"email": "mrsang@iohub.dev"
|
"email": "mrsang@iohub.dev"
|
||||||
},
|
},
|
||||||
"version":"0.0.3-a",
|
"version": "0.0.4-a",
|
||||||
"category":"Other",
|
"category": "Other",
|
||||||
"iconclass":"fa fa-cog",
|
"iconclass": "fa fa-cog",
|
||||||
"mimes":["none"],
|
"mimes": [
|
||||||
"dependencies":[],
|
"none"
|
||||||
"locale": {}
|
],
|
||||||
|
"dependencies": [],
|
||||||
|
"locale": {
|
||||||
|
"en_GB": {
|
||||||
|
"Installing...": "Installing...",
|
||||||
|
"Running {0}...": "Running {0}...",
|
||||||
|
"{0} is not an application": "{0} is not an application",
|
||||||
|
"No target: {0}": "No target: {0}",
|
||||||
|
"### RUNNING STAGE: {0}###": "### RUNNING STAGE: {0}###"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -208,7 +208,7 @@ namespace OS {
|
|||||||
{
|
{
|
||||||
const target = options.targets[name];
|
const target = options.targets[name];
|
||||||
if(!target)
|
if(!target)
|
||||||
return reject(__(`No target: ${name}`));
|
return reject(__("No target: {0}", name));
|
||||||
|
|
||||||
if(target.depend)
|
if(target.depend)
|
||||||
{
|
{
|
||||||
@ -219,7 +219,7 @@ namespace OS {
|
|||||||
await this.require(target.require);
|
await this.require(target.require);
|
||||||
}
|
}
|
||||||
if(this.logger)
|
if(this.logger)
|
||||||
this.logger.info(__(`### RUNNING STAGE: ${name}###`).__());
|
this.logger.info(__("### RUNNING STAGE: {0}###", name).__());
|
||||||
if(target.jobs)
|
if(target.jobs)
|
||||||
for(const job of target.jobs)
|
for(const job of target.jobs)
|
||||||
{
|
{
|
||||||
|
@ -195,7 +195,7 @@
|
|||||||
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/libantosdk/README.md",
|
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/libantosdk/README.md",
|
||||||
"category": "Other",
|
"category": "Other",
|
||||||
"author": "Xuan Sang LE",
|
"author": "Xuan Sang LE",
|
||||||
"version": "0.0.3-a",
|
"version": "0.0.4-a",
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/libantosdk/build/release/libantosdk.zip"
|
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/libantosdk/build/release/libantosdk.zip"
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user