Skip to content

Commit f27072c

Browse files
committed
fix: Dynamic AppLoc for Streaming Apps
1 parent 6e37cf5 commit f27072c

File tree

4 files changed

+20
-50
lines changed

4 files changed

+20
-50
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 & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -166,24 +166,10 @@ 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 = [
183170
...new Set([
184171
...dependencyFilePaths,
185-
...dependencyFilePathsForCreateFile,
186-
...dependencyFilePathsForGsubScript
172+
...dependencyFilePathsForCreateFile
187173
])
188174
]
189175
}
@@ -286,15 +272,26 @@ async function getCreateFileScript(serverType: ServerType) {
286272
export function getWebServiceScriptInvocation(
287273
serverType: ServerType,
288274
isSASFile: boolean = true,
289-
encoded: boolean = false
275+
encoded: boolean = false,
276+
fileName?: string,
290277
) {
291278
const encodedParam = encoded ? ', intype=BASE64' : ''
292279

293280
switch (serverType) {
294281
case ServerType.SasViya:
282+
let swapString = ''
283+
284+
if (fileName) {
285+
const extension = fileName?.split('.').pop()?.toLowerCase() || ''
286+
287+
if (['html', 'css', 'js'].includes(extension)) {
288+
swapString = `,swap=compiled_apploc apploc`
289+
}
290+
}
291+
295292
return isSASFile
296293
? `%mv_createwebservice(path=&appLoc/&path, name=&service, code=sascode,replace=yes)`
297-
: `%mv_createfile(path=&appLoc/&path, name=&filename, inref=filecode${encodedParam})`
294+
: `%mv_createfile(path=&appLoc/&path, name=&filename, inref=filecode${encodedParam}${swapString})`
298295
case ServerType.Sas9:
299296
return isSASFile
300297
? `%mm_createwebservice(path=&appLoc/&path, name=&service, code=sascode, server=&serverName, replace=yes)`
@@ -458,7 +455,7 @@ ${content}\n
458455
run;
459456
${
460457
serverType !== ServerType.Sasjs
461-
? getWebServiceScriptInvocation(serverType, false, true)
458+
? getWebServiceScriptInvocation(serverType, false, true, fileName)
462459
: ''
463460
}
464461
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_;

0 commit comments

Comments
 (0)