-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Saving files locally in both yaml and json format. (#904)
Co-authored-by: Evan Shi <[email protected]>
- Loading branch information
1 parent
becf415
commit 0a37d2b
Showing
19 changed files
with
14,288 additions
and
7,441 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@ensembleui/js-commons": patch | ||
"@ensembleui/cli": patch | ||
--- | ||
|
||
Add apps:get command for copying yaml to local folder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"extends": ["oclif", "oclif-typescript", "prettier"] | ||
"extends": ["oclif", "oclif-typescript", "prettier"], | ||
"ignorePatterns": ["dist/"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
/node_modules | ||
oclif.manifest.json | ||
|
||
|
||
tsconfig.tsbuildinfo | ||
yarn.lock | ||
package-lock.json | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { getFirestoreApplicationTransporter, getLocalApplicationTransporter } from '@ensembleui/js-commons' | ||
import {Args, Command, Flags} from '@oclif/core' | ||
import { get } from 'lodash-es' | ||
import path from 'node:path' | ||
|
||
import { db } from '../../firebase.js' | ||
import { getStoredToken, signInWithEmailPassword } from '../../utils.js' | ||
|
||
export default class AppsGet extends Command { | ||
static override args = { | ||
id: Args.string({description: 'Ensemble App ID', required: true}), | ||
} | ||
|
||
static override description = 'Get a local copy of the app' | ||
|
||
static override examples = [ | ||
'<%= config.bin %> <%= command.id %>', | ||
] | ||
|
||
static override flags = { | ||
dir: Flags.string({char: 'd', description: 'Where the app should be copied to'}), | ||
} | ||
|
||
public async run(): Promise<void> { | ||
const { args, flags } = await this.parse(AppsGet); | ||
const cachedAuth = getStoredToken(); | ||
if (!cachedAuth) { | ||
this.error('Please login first.') | ||
} | ||
|
||
const { email, password } = cachedAuth; | ||
await signInWithEmailPassword(email, password); | ||
|
||
const appId = args.id; | ||
const dir = path.join(process.cwd(), flags.dir ?? appId); | ||
|
||
try { | ||
const firestoreAppTransporter = getFirestoreApplicationTransporter(db); | ||
const localAppTransporter = getLocalApplicationTransporter(this.config.dataDir); | ||
const app = await firestoreAppTransporter.get(appId); | ||
await localAppTransporter.put(app, dir); | ||
|
||
this.log(`Wrote app ${app.name} to ${dir}`) | ||
} catch (error) { | ||
this.error(get(error, "message") ?? "An error occurred") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import {runCommand} from '@oclif/test' | ||
import {expect} from 'chai' | ||
|
||
describe.skip('apps:get', () => { | ||
it('runs apps:get cmd', async () => { | ||
const {stdout} = await runCommand('apps:get') | ||
expect(stdout).to.contain('hello world') | ||
}) | ||
|
||
it('runs apps:get --name oclif', async () => { | ||
const {stdout} = await runCommand('apps:get --name oclif') | ||
expect(stdout).to.contain('hello oclif') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from "./dto"; | ||
export * from "./service"; | ||
export * from "./firebase"; | ||
export * from "./transporter"; | ||
export * from "./service"; | ||
export * from "./local-files"; |
Oops, something went wrong.