Skip to content

Commit

Permalink
fix: sasjs run default contextName, removed localRcFile functions
Browse files Browse the repository at this point in the history
  • Loading branch information
medjedovicm committed Dec 1, 2020
1 parent 7fbd04f commit 2201b4e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 44 deletions.
5 changes: 2 additions & 3 deletions src/commands/run.js
Expand Up @@ -50,12 +50,11 @@ async function executeOnSasViya(filePath, buildTarget, linesToExecute) {
serverType: buildTarget.serverType,
debug: true
})

const contextName = await getVariable('contextName', buildTarget)

if (!contextName) {
throw new Error(
'Compute Context Name is required for SAS Viya deployments.\n Please ensure that `contextName` is present in your build target configuration or in your .env file, and try again.\n'
)
contextName = sasjs.getSasjsConfig().contextName
}

const accessToken = await getAccessToken(buildTarget)
Expand Down
14 changes: 0 additions & 14 deletions src/utils/config-utils.js
Expand Up @@ -151,15 +151,6 @@ export async function getGlobalRcFile() {
: sasjsRcFileContent
}

export async function getLocalRcFile() {
const projectRoot = await getProjectRoot()
if (!projectRoot) {
return null
}
const config = await getConfiguration(path.join(projectRoot, '.sasjsrc'))
return config
}

export async function saveGlobalRcFile(content) {
const homeDir = require('os').homedir()
const rcFilePath = path.join(homeDir, '.sasjsrc')
Expand All @@ -169,11 +160,6 @@ export async function saveGlobalRcFile(content) {
console.log(chalk.greenBright(`Config saved to '${rcFilePath}'.`))
}

export async function saveLocalRcFile(content) {
const projectRoot = await getProjectRoot()
await createFile(path.join(projectRoot, '.sasjsrc'), content)
}

export async function getFolders(sasOnly = false) {
const configPath = sasOnly ? '../config-sasonly.json' : '../config.json'
const config = await readFile(path.join(__dirname, configPath))
Expand Down
31 changes: 4 additions & 27 deletions src/utils/utils.js
Expand Up @@ -3,7 +3,6 @@ import chalk from 'chalk'
import path from 'path'
import ora from 'ora'
import { fileExists, createFile, readFile } from './file-utils'
import { getLocalRcFile } from './config-utils'

async function inExistingProject(folderPath) {
const packageJsonExists = await fileExists(
Expand Down Expand Up @@ -180,44 +179,22 @@ export function chunk(text, maxLength = 220) {

export async function getVariable(name, target) {
let value = process.env[name]

if (value) {
return value
}

value = target && target.tgtDeployVars ? target.tgtDeployVars[name] : null
if (value) {
return value
}

value = target && target.tgtBuildVars ? target.tgtBuildVars[name] : null
if (value) {
return value
}

const localRcFile = await getLocalRcFile()
if (localRcFile && localRcFile.targets) {
const currentTarget = localRcFile.targets.find(
(t) => t.name === target.name
)
if (currentTarget) {
value =
currentTarget && currentTarget.tgtDeployVars
? currentTarget.tgtDeployVars[name]
: null
if (value) {
return value
}
value =
currentTarget && currentTarget.tgtBuildVars
? currentTarget.tgtBuildVars[name]
: null
if (value) {
return value
}
return currentTarget && currentTarget.authInfo
? currentTarget.authInfo[name]
: null
}
return null
}
return null
}

/**
Expand Down

0 comments on commit 2201b4e

Please sign in to comment.