1- import { parse } from "https://deno.land/[email protected] /flags/mod.ts" ; 2- import {
3- createHttpError ,
4- } from "https://deno.land/[email protected] /http/http_errors.ts" ; 1+ import { parseArgs } from "@std/cli/parse-args" ;
2+ import { createHttpError } from "@std/http/http-errors" ;
53
64// Regex for https://deno.land/x/deno_slack_api@x .x.x/
75const API_REGEX =
8- / ( h t t p s : \/ \/ d e n o .l a n d \/ x \/ d e n o _ s l a c k _ a p i @ [ 0 - 9 ] + \. [ 0 - 9 ] + \. [ 0 - 9 ] + \/ ) / g;
6+ / ( h t t p s : \/ \/ d e n o .l a n d \/ x \/ d e n o _ s l a c k _ a p i @ [ 0 - 9 ] \. [ 0 - 9 ] + \. [ 0 - 9 ] + \/ ) / g;
97
108async function main ( ) {
11- const flags = parse ( Deno . args , {
12- string : [ "import-map" , "api" ] ,
9+ const flags = parseArgs ( Deno . args , {
10+ string : [ "import-map" , "api" , "parent-import-map" ] ,
1311 default : {
1412 "import-map" : `${ Deno . cwd ( ) } /import_map.json` ,
1513 "api" : "../deno-slack-api/src/" ,
14+ "parent-import-map" : undefined ,
1615 } ,
1716 } ) ;
1817
@@ -37,7 +36,18 @@ async function main() {
3736 ) ,
3837 } ;
3938
40- const importMapJsonOut = JSON . stringify ( importMap ) ;
39+ if ( flags [ "parent-import-map" ] ) {
40+ const parentImportMapJsonIn = await Deno . readTextFile (
41+ flags [ "parent-import-map" ] ,
42+ ) ;
43+ console . log ( "parent `import_map.json` in content:" , parentImportMapJsonIn ) ;
44+ const parentImportMap = JSON . parse ( parentImportMapJsonIn ) ;
45+ for ( const entry of Object . entries ( parentImportMap [ "imports" ] ) ) {
46+ importMap [ "imports" ] [ entry [ 0 ] ] = entry [ 1 ] ;
47+ }
48+ }
49+
50+ const importMapJsonOut = JSON . stringify ( importMap , null , 2 ) ;
4151 console . log ( "`import_map.json` out content:" , importMapJsonOut ) ;
4252
4353 await Deno . writeTextFile ( flags [ "import-map" ] , importMapJsonOut ) ;
0 commit comments