@geastack/cli 0.1.111 → 0.1.112

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geastack/cli",
3
- "version": "0.1.111",
3
+ "version": "0.1.112",
4
4
  "description": "Command-line front door for GeaStack apps, targets, and local toolchains.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -1,4 +1,4 @@
1
- import { syncNativeResources } from '../native-resources.mjs'
1
+ import { nativeResourceTargets, syncNativeResources } from '../native-resources.mjs'
2
2
  import { readdirSync } from 'node:fs'
3
3
  import path from 'node:path'
4
4
 
@@ -18,7 +18,7 @@ export async function appsCommand(ctx, parsed, rest, options) {
18
18
  case 'sync-native-resources': {
19
19
  const app=resolveRequestedApp(ctx,parsed,args);assertValidApp(app);const target=option(parsed,'target',''),output=option(parsed,'output','');
20
20
  if(!target||!output)fail('sync-native-resources requires --target and --output',ExitCode.usage);
21
- if(!app.targets[target]||!['macos','raspberry-pi-os'].includes(target))fail('Unsupported or disabled native resource target',ExitCode.usage);
21
+ if(!app.targets[target]||!nativeResourceTargets.includes(target))fail('Unsupported or disabled native resource target',ExitCode.usage);
22
22
  options.stdout(JSON.stringify(syncNativeResources(app.root,target,app.targetConfig[target]?.nativeResources||{},path.resolve(output))));return 0
23
23
  }
24
24
  case 'inspect': return inspectApp(ctx, parsed, args, options)
@@ -13,7 +13,7 @@ export function resolveNativeLink(root, target, config = {}) {
13
13
  if (libraries.length && !['macos', 'raspberry-pi-os', 'ios', 'tvos'].includes(target)) throw new Error(`nativeLibraries are not supported by ${target}`)
14
14
  if (frameworks.length && !['macos', 'ios', 'tvos'].includes(target)) throw new Error('frameworks are supported only by macos, ios and tvos')
15
15
  if (includeDirectories.length && !['raspberry-pi-os', 'windows', 'ios', 'tvos'].includes(target)) throw new Error('nativeIncludeDirectories are supported only by raspberry-pi-os, windows, ios and tvos')
16
- if (systemLibraries.length && !['raspberry-pi-os', 'windows'].includes(target)) throw new Error('nativeSystemLibraries are supported only by raspberry-pi-os and windows')
16
+ if (systemLibraries.length && !['raspberry-pi-os', 'windows', 'macos', 'ios', 'tvos'].includes(target)) throw new Error('nativeSystemLibraries are supported only by raspberry-pi-os, windows, macos, ios and tvos')
17
17
  const includes = includeDirectories.map(value => {
18
18
  if (path.isAbsolute(value) || value.split(/[\\/]/).includes('..') || /[\x00-\x1f\x7f]/.test(value)) throw new Error('Invalid nativeIncludeDirectories entry')
19
19
  const directory = fs.realpathSync(path.join(realRoot,value)), relative=path.relative(realRoot,directory)
@@ -4,9 +4,10 @@ import crypto from 'node:crypto'
4
4
  const exists=file=>{try{fs.lstatSync(file);return true}catch(error){if(error.code==='ENOENT')return false;throw error}}
5
5
  function fileHash(file){const fd=fs.openSync(file,'r'),hash=crypto.createHash('sha256'),buffer=Buffer.alloc(1048576);try{for(;;){const count=fs.readSync(fd,buffer,0,buffer.length,null);if(!count)break;hash.update(buffer.subarray(0,count))}return hash.digest('hex')}finally{fs.closeSync(fd)}}
6
6
  const safeName=value=>typeof value==='string' && /^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(value) && !['Fonts','FontLicenses','Frameworks','MacOS'].includes(value)
7
+ export const nativeResourceTargets=['macos','raspberry-pi-os','windows','ios','tvos']
7
8
  export function resolveNativeResources(root, target, raw = {}) {
8
9
  if(!raw||typeof raw!=='object'||Array.isArray(raw))throw Error('nativeResources must be a destination-to-directory object')
9
- if(Object.keys(raw).length && !['macos','raspberry-pi-os','windows','ios','tvos'].includes(target))throw Error(`nativeResources are not supported by ${target}`)
10
+ if(Object.keys(raw).length && !nativeResourceTargets.includes(target))throw Error(`nativeResources are not supported by ${target}`)
10
11
  const base=fs.realpathSync(root),result={};let count=0,total=0
11
12
  for(const [name,value]of Object.entries(raw)){
12
13
  if(!safeName(name)||typeof value!=='string'||!value||path.isAbsolute(value)||value.split(/[\\/]/).includes('..')||/[\x00-\x1f\x7f]/.test(value))throw Error('Invalid nativeResources destination or source')