Skip to content

Commit

Permalink
Merge pull request #227 from sasjs/issue211
Browse files Browse the repository at this point in the history
fix: deploy is forced by default
  • Loading branch information
krishna-acondy authored Nov 20, 2020
2 parents d41f744 + 1a90cbd commit da84b2d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 25 deletions.
5 changes: 2 additions & 3 deletions src/commands/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ export async function build(
targetName = null,
compileOnly = false,
compileBuildOnly = false,
compileBuildDeployOnly = false,
isForced = false
compileBuildDeployOnly = false
) {
const CONSTANTS = require('../constants')

Expand All @@ -55,7 +54,7 @@ export async function build(
if (compileBuildDeployOnly) {
await compile(targetName)
await createFinalSasFiles()
return await deploy(targetName, targetToBuild, isForced)
return await deploy(targetName, targetToBuild)
}

if (compileBuildOnly) {
Expand Down
14 changes: 5 additions & 9 deletions src/commands/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ import {
let targetToBuild = null
let executionSession

export async function deploy(
targetName = null,
preTargetToBuild = null,
isForced = false
) {
export async function deploy(targetName = null, preTargetToBuild = null) {
if (preTargetToBuild) targetToBuild = preTargetToBuild
else {
const { target } = await findTargetInConfiguration(targetName)
Expand All @@ -48,7 +44,7 @@ export async function deploy(
chalk.cyanBright(`Executing deployServicePack to update SAS server.`)
)

await deployToSasViyaWithServicePack(targetToBuild, isForced)
await deployToSasViyaWithServicePack(targetToBuild)

console.log('Job execution completed!')
}
Expand Down Expand Up @@ -153,7 +149,7 @@ async function getSASjsAndAccessToken(buildTarget) {
}
}

async function deployToSasViyaWithServicePack(buildTarget, isForced) {
async function deployToSasViyaWithServicePack(buildTarget) {
const sasjs = new SASjs({
serverUrl: buildTarget.serverUrl,
appLoc: buildTarget.appLoc,
Expand Down Expand Up @@ -194,11 +190,11 @@ async function deployToSasViyaWithServicePack(buildTarget, isForced) {
null,
null,
access_token,
isForced
true
)
}

return await sasjs.deployServicePack(jsonObject, null, null, null, isForced)
return await sasjs.deployServicePack(jsonObject, null, null, null, true)
}

async function deployToSasViya(
Expand Down
3 changes: 3 additions & 0 deletions src/commands/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ export async function printHelpText() {
'serverUrl'
)} - The full path to the server (eg https://yourserver)
* ${chalk.cyanBright('serverType')} - Eg SAS9 or SASVIYA
NOTE: By default deploy will overwrite an existing deploy (force deploy).
* ${chalk.greenBright(
'compilebuilddeploy <targetName>'
)} - executes script file specified in the ${chalk.cyanBright(
Expand Down
16 changes: 4 additions & 12 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,12 @@ export async function compileServices(targetName) {
export async function deployServices(commandLine) {
const command = new Command(commandLine)
let targetName = command.getFlagValue('target')
const isForced = command.getFlagValue('force')

if (!targetName) {
targetName = command.getTargetWithoutFlag()
}

await deploy(targetName, null, isForced)
await deploy(targetName, null)
.then(() =>
console.log(
chalk.greenBright.bold.italic(
Expand All @@ -155,11 +154,8 @@ export async function deployServices(commandLine) {
console.log(
chalk.redBright(
'An error has occurred when building services.',
`${message}${
status === 409
? '\nIf you still want to deploy, use force flag (-f) after target name.'
: ''
}${details ? '\n' + details : ''}`
`${message}
${details ? '\n' + details : ''}`
)
)
} else {
Expand Down Expand Up @@ -234,11 +230,7 @@ export async function compileBuildDeployServices(commandLine) {
console.log(
chalk.redBright(
'An error has occurred when building services.',
`${message}${
status === 409
? '\nIf you still want to deploy, use force flag (-f) after target name.'
: ''
}${details ? '\n' + details : ''}`
`${message}${details ? '\n' + details : ''}`
)
)
} else {
Expand Down
4 changes: 3 additions & 1 deletion test/utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ describe('generateTimestamp', () => {
beforeAll(() => {
const currentDate = new Date('2020-10-02T10:10:10.10Z')
realDate = Date
global.Date = class extends Date {
global.Date = class extends (
Date
) {
constructor(date) {
if (date) {
return super(date)
Expand Down

0 comments on commit da84b2d

Please sign in to comment.