Skip to content

Commit dd2836c

Browse files
authored
Merge pull request #1405 from sasjs/issue-1403
Dynamic AppLoc for Streaming Apps
2 parents 6e37cf5 + 1bc58d9 commit dd2836c

File tree

5 files changed

+23
-54
lines changed

5 files changed

+23
-54
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
},
5353
"dependencies": {
5454
"@sasjs/adapter": "4.11.3",
55-
"@sasjs/core": "4.57.2",
55+
"@sasjs/core": "4.58.1",
5656
"@sasjs/lint": "2.4.3",
5757
"@sasjs/utils": "3.5.2",
5858
"adm-zip": "0.5.10",

src/commands/build/build.ts

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -166,25 +166,8 @@ async function getBuildInfo(target: Target, streamWeb: boolean) {
166166
macroCorePath
167167
)
168168

169-
// The gsubScript is used to perform the replacement of the appLoc within
170-
// the deployed index.html file. This only happens when deploying using the
171-
// SAS Program (build.sas) approach.
172-
const gsubScript = await readFile(
173-
`${process.sasjsConstants.macroCorePath}/base/mp_replace.sas`
174-
)
175-
buildConfig += `${gsubScript}\n`
176-
const dependencyFilePathsForGsubScript = await getDependencyPaths(
177-
gsubScript,
178-
macroFolders,
179-
macroCorePath
180-
)
181-
182169
dependencyFilePaths = [
183-
...new Set([
184-
...dependencyFilePaths,
185-
...dependencyFilePathsForCreateFile,
186-
...dependencyFilePathsForGsubScript
187-
])
170+
...new Set([...dependencyFilePaths, ...dependencyFilePathsForCreateFile])
188171
]
189172
}
190173

@@ -286,15 +269,26 @@ async function getCreateFileScript(serverType: ServerType) {
286269
export function getWebServiceScriptInvocation(
287270
serverType: ServerType,
288271
isSASFile: boolean = true,
289-
encoded: boolean = false
272+
encoded: boolean = false,
273+
fileName?: string
290274
) {
291275
const encodedParam = encoded ? ', intype=BASE64' : ''
292276

293277
switch (serverType) {
294278
case ServerType.SasViya:
279+
let swapString = ''
280+
281+
if (fileName) {
282+
const extension = fileName?.split('.').pop()?.toLowerCase() || ''
283+
284+
if (['html', 'css', 'js'].includes(extension)) {
285+
swapString = `,swap=compiled_apploc apploc`
286+
}
287+
}
288+
295289
return isSASFile
296290
? `%mv_createwebservice(path=&appLoc/&path, name=&service, code=sascode,replace=yes)`
297-
: `%mv_createfile(path=&appLoc/&path, name=&filename, inref=filecode${encodedParam})`
291+
: `%mv_createfile(path=&appLoc/&path, name=&filename, inref=filecode${encodedParam}${swapString})`
298292
case ServerType.Sas9:
299293
return isSASFile
300294
? `%mm_createwebservice(path=&appLoc/&path, name=&service, code=sascode, server=&serverName, replace=yes)`
@@ -458,7 +452,7 @@ ${content}\n
458452
run;
459453
${
460454
serverType !== ServerType.Sasjs
461-
? getWebServiceScriptInvocation(serverType, false, true)
455+
? getWebServiceScriptInvocation(serverType, false, true, fileName)
462456
: ''
463457
}
464458
filename filecode clear;

src/commands/build/internal/getLaunchPageCode.ts

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,6 @@ data _null_;
1515
run;
1616
`
1717
const SASViyaCode = (streamServiceName: string) => `
18-
19-
/**
20-
* The streamService we just deployed (as a _FILE) had the compile-time appLoc
21-
* In this section we replace with the deploy-time appLoc
22-
*/
23-
24-
filename _homein filesrvc
25-
folderPath="&apploc/services"
26-
filename="${streamServiceName}.html"
27-
recfm=v
28-
lrecl=1048544;
29-
30-
%let local_file=%sysfunc(pathname(work))/service.html;
31-
filename _homeout "&local_file";
32-
33-
data _null_;
34-
rc=fcopy('_homein','_homeout');
35-
put rc=;
36-
run;
37-
38-
%mp_replace(infile="&local_file", findvar=compiled_apploc, replacevar=apploc)
39-
40-
data _null_;
41-
rc=fcopy('_homeout','_homein');
42-
put rc=;
43-
run;
44-
4518
/* Tell the user where the app was deployed so they can open it */
4619
options notes;
4720
data _null_;

src/commands/deploy/spec/deploy.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,9 @@ describe('deploy', () => {
250250
}
251251
})
252252

253-
await deploy(target, true)
253+
await deploy(target, true).catch((err) => {
254+
// error is expected, nothing to do
255+
})
254256

255257
expect(process.logger.error).toHaveBeenCalledWith(
256258
`Unable to process script located at ${path.join(

0 commit comments

Comments
 (0)