1414 * limitations under the License.
1515 */
1616
17+ import { access , symlink } from "fs/promises" ;
1718import { createServer } from "http" ;
1819import type { Server } from "http" ;
1920import { dirname , join } from "path" ;
@@ -28,10 +29,26 @@ export const CDN_PUBLIC_PATH = join(
2829 "../../../core/js-client/dist/browser" ,
2930) ;
3031
32+ export const JS_CLIENT_DEPS_PATH = join (
33+ __dirname ,
34+ "../../../core/js-client/node_modules" ,
35+ ) ;
36+
3137export const startCdn = ( port : number ) => {
3238 return startContentServer ( port , CDN_PUBLIC_PATH ) ;
3339} ;
3440
41+ export const createSymlinkIfNotExists = async (
42+ target : string ,
43+ path : string ,
44+ ) => {
45+ try {
46+ await access ( path ) ;
47+ } catch {
48+ await symlink ( target , path ) ;
49+ }
50+ } ;
51+
3552export const startContentServer = (
3653 port : number ,
3754 publicDir : string ,
@@ -44,6 +61,22 @@ export const startContentServer = (
4461 source : "/js-client.min.js" ,
4562 destination : "/source/index.umd.cjs" ,
4663 } ,
64+ // TODO:
65+ // something like this
66+ // {
67+ // source: "/@fluencelabs/:name(\\w+)@:version([\\d.]+)/:path*",
68+ // destination: "/deps/@fluencelabs/:name/:path",
69+ // }
70+ // not supported for some reason. Need to manually iterate over all possible paths
71+ {
72+ source : "/@fluencelabs/:name([\\w-]+)@:version([\\d.]+)/dist/:asset" ,
73+ destination : "/node_modules/@fluencelabs/:name/dist/:asset" ,
74+ } ,
75+ {
76+ source :
77+ "/@fluencelabs/:name([\\w-]+)@:version([\\d.]+)/dist/:prefix/:asset" ,
78+ destination : "/node_modules/@fluencelabs/:name/dist/:prefix/:asset" ,
79+ } ,
4780 ] ,
4881 headers : [
4982 {
0 commit comments