Skip to content

Commit

Permalink
feat: apt command
Browse files Browse the repository at this point in the history
  • Loading branch information
zdm committed Mar 26, 2024
1 parent 3fa17d3 commit 21a57b8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 15 deletions.
16 changes: 15 additions & 1 deletion bin/softvisio-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,18 @@ const spec = {

const cli = await CLI.parse( spec );

await new cli.module().run();
try {
var res = result.try( await new cli.module().run(), { "allowUndefined": true } );
}
catch ( e ) {
res = result.catch( e, { "log": false } );
}

if ( res.ok ) {
process.exit( 0 );
}
else {
console.log( res + "" );

process.exit( 1 );
}
6 changes: 2 additions & 4 deletions lib/commands/apt/build-base-images.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ export default class extends Command {

// public
async run () {
const rootPackage = this._findRootPackage();

if ( !rootPackage ) this._throwError( `Unable to find root package` );
if ( !this.root ) return result( [ 5 - 0, `Unable to find root package` ] );

var res;

Expand All @@ -51,7 +49,7 @@ export default class extends Command {
],
{
"stdio": "inherit",
"cwd": this.resources + "/base-images",
"cwd": this.root + "/base-images",
}
);
if ( !res.ok ) return res;
Expand Down
24 changes: 14 additions & 10 deletions lib/commands/apt/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,43 @@ import Command from "#lib/command";
import "#core/result";
import { readConfig } from "#core/config";
import childProcess from "node:child_process";
import env from "#core/env";
import Git from "#core/api/git";

export default class extends Command {
#rootPackage;
#config;
#codenames;
#git;

constructor () {
super();

this.#rootPackage = this._findRootPackage();
}

// properties
get root () {
return env.root;
return this.#rootPackage?.root;
}

get repository () {
return this.root;
// XXX
get dists () {
return this.root + "/dists";
}

// XXX
get resources () {
return this.root + "/resources";
}

get config () {
if ( !this.#config ) {
this.#config = readConfig( this.resources + "/config.yaml" );
this.#config = readConfig( this.root + "/config.yaml" );
}

return this.#config;
}

get git () {
this.#git ??= new Git( this.repository );

return this.#git;
return this.#rootPackage.git;
}

get repositoryId () {
Expand Down

0 comments on commit 21a57b8

Please sign in to comment.