-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
1,390 additions
and
2,422 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
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
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 @@ | ||
const salesforcePrettierConfig = require("@salesforce/prettier-config"); | ||
|
||
module.exports = { | ||
...salesforcePrettierConfig, | ||
singleQuote: false, | ||
}; |
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,34 +1,35 @@ | ||
import { SfdxCommand } from '@salesforce/command'; | ||
import type { AnyJson } from '@salesforce/ts-types'; | ||
import { SfCommand, requiredOrgFlagWithDeprecations } from '@salesforce/sf-plugins-core'; | ||
import { promisify } from 'util'; | ||
import child_process = require('child_process'); | ||
const exec = promisify(child_process.exec); | ||
|
||
export default class ExportOrgUsingAuthUrlCommand extends SfdxCommand { | ||
export type ExportOrgUsingAuthUrlResult = { | ||
sfdxAuthUrl: string; | ||
}; | ||
|
||
export class ExportOrgUsingAuthUrlCommand extends SfCommand<ExportOrgUsingAuthUrlResult> { | ||
public static description = | ||
'Print a Sfdx Auth Url.\nThis is a wrapper for sfdx force:org:display --verbose.'; | ||
|
||
public static examples = [ | ||
`$ sfdx <%= command.id %> --targetusername [email protected] | ||
`$ <%= config.bin %> <%= command.id %> --targetusername [email protected] | ||
force://PlatformCLI::[email protected] | ||
` | ||
]; | ||
|
||
public static args = []; | ||
|
||
protected static flagsConfig = {}; | ||
|
||
// Comment this out if your command does not require an org username | ||
protected static requiresUsername = true; | ||
public static readonly flags = { | ||
"target-org": requiredOrgFlagWithDeprecations, | ||
} | ||
|
||
public async run(): Promise<AnyJson> { | ||
public async run(): Promise<ExportOrgUsingAuthUrlResult> { | ||
const { flags } = await this.parse(ExportOrgUsingAuthUrlCommand); | ||
const args = ['--verbose', '--json']; | ||
if (this.flags.targetusername) { | ||
args.push(...['--targetusername', this.flags.targetusername]); | ||
if (flags['target-org']) { | ||
args.push(...['--targetusername', flags["target-org"].getUsername()!]); | ||
} | ||
const execResult = await exec(`sfdx force:org:display ${args.join(' ')}`); | ||
const stdoutJson = JSON.parse(execResult.stdout); | ||
this.ux.log(stdoutJson.result.sfdxAuthUrl); | ||
return { sfdxAuthUrl: stdoutJson.result.sfdxAuthUrl }; | ||
const { result } = JSON.parse(execResult.stdout); | ||
this.log(result.sfdxAuthUrl); | ||
return { sfdxAuthUrl: result.sfdxAuthUrl }; | ||
} | ||
} |
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,37 +1,35 @@ | ||
import { flags, SfdxCommand } from '@salesforce/command'; | ||
import type { AnyJson } from '@salesforce/ts-types'; | ||
import { Args } from '@oclif/core'; | ||
import { Flags, SfCommand } from '@salesforce/sf-plugins-core'; | ||
import { promises as fsPromises } from 'fs'; | ||
import type { FileResult } from 'tmp'; | ||
import { promisify } from 'util'; | ||
import child_process = require('child_process'); | ||
import tmp = require('tmp'); | ||
const exec = promisify(child_process.exec); | ||
|
||
export default class ImportOrgUsingAuthUrlCommand extends SfdxCommand { | ||
export class ImportOrgUsingAuthUrlCommand extends SfCommand<void> { | ||
public static description = | ||
'Authorize an org.\nThis is a wrapper for sfdx auth:sfdxurl:store without requiring a sfdxAuthUrl file.'; | ||
|
||
public static examples = [ | ||
'$ sfdx <%= command.id %> --setalias myOrg force://PlatformCLI::[email protected]' | ||
'$ <%= config.bin %> <%= command.id %> --setalias myOrg force://PlatformCLI::[email protected]' | ||
]; | ||
|
||
public static args = [ | ||
{ | ||
name: 'sfdxAuthUrl' | ||
} | ||
]; | ||
public static readonly args = { | ||
sfdxAuthUrl: Args.string() | ||
}; | ||
|
||
protected static flagsConfig = { | ||
setalias: flags.string({ | ||
public static readonly flags = { | ||
setalias: Flags.string({ | ||
description: 'set an alias for the authenticated org', | ||
char: 'a' | ||
}), | ||
setdefaultdevhubusername: flags.boolean({ | ||
setdefaultdevhubusername: Flags.boolean({ | ||
description: | ||
'set the authenticated org as the default dev hub org for scratch org creation', | ||
char: 'd' | ||
}), | ||
setdefaultusername: flags.boolean({ | ||
setdefaultusername: Flags.boolean({ | ||
description: | ||
'set the authenticated org as the default username that all commands run against', | ||
char: 's' | ||
|
@@ -40,24 +38,27 @@ export default class ImportOrgUsingAuthUrlCommand extends SfdxCommand { | |
|
||
protected tempObj!: FileResult; | ||
|
||
public async run(): Promise<AnyJson> { | ||
public async run(): Promise<void> { | ||
const { flags, args } = await this.parse(ImportOrgUsingAuthUrlCommand); | ||
this.tempObj = tmp.fileSync(); | ||
const sfdxAuthUrlFile = this.tempObj.name; | ||
const sfdxAuthUrl = this.args.sfdxAuthUrl; | ||
if (!args.sfdxAuthUrl) { | ||
throw new Error("missing argument sfdxAuthUrl"); | ||
} | ||
const sfdxAuthUrl = args.sfdxAuthUrl; | ||
await fsPromises.writeFile(sfdxAuthUrlFile, sfdxAuthUrl); | ||
|
||
const args = ['--sfdxurlfile', sfdxAuthUrlFile]; | ||
if (this.flags.setalias) { | ||
args.push(...['--setalias', this.flags.setalias]); | ||
const orgLoginArgs = ['--sfdxurlfile', sfdxAuthUrlFile]; | ||
if (flags.setalias) { | ||
orgLoginArgs.push(...['--setalias', flags.setalias]); | ||
} | ||
if (this.flags.setdefaultusername) { | ||
args.push('--setdefaultusername'); | ||
if (flags.setdefaultusername) { | ||
orgLoginArgs.push('--setdefaultusername'); | ||
} | ||
if (this.flags.setdefaultdevhubusername) { | ||
args.push('--setdefaultdevhubusername'); | ||
if (flags.setdefaultdevhubusername) { | ||
orgLoginArgs.push('--setdefaultdevhubusername'); | ||
} | ||
await exec(`sfdx auth:sfdxurl:store ${args.join(' ')}`); | ||
return {}; | ||
await exec(`sfdx auth:sfdxurl:store ${orgLoginArgs.join(' ')}`); | ||
} | ||
|
||
public async finally(): Promise<void> { | ||
|
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 +1 @@ | ||
export default {}; | ||
export {}; |
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,15 +1,12 @@ | ||
{ | ||
"extends": "@salesforce/dev-config/tsconfig", | ||
"include": ["./src/**/*.ts"], | ||
"compilerOptions": { | ||
"outDir": "lib", | ||
"module": "commonjs", | ||
"target": "es2020", | ||
"lib": ["es2020"], | ||
"sourceMap": true, | ||
"declaration": true, | ||
"moduleResolution": "node", | ||
"rootDir": "src", | ||
"skipLibCheck": true, | ||
"strictNullChecks": true, | ||
"esModuleInterop": true, | ||
"strict": true, | ||
"noUnusedLocals": true | ||
}, | ||
"include": ["./src/**/*.ts"] | ||
"declaration": false, | ||
} | ||
} |
Oops, something went wrong.