File tree Expand file tree Collapse file tree 8 files changed +47
-3
lines changed
Expand file tree Collapse file tree 8 files changed +47
-3
lines changed Original file line number Diff line number Diff line change @@ -20,4 +20,4 @@ import '@intentjs/ts-node/esm';
2020/**
2121 * Import console commands entrypoint
2222 */
23- await import ( './ bin/console.js ' ) ;
23+ await import ( '# bin/console' ) ;
Original file line number Diff line number Diff line change 1515 },
1616 "homepage" : " https://github.com/intentjs/new-app-starter" ,
1717 "imports" : {
18+ "#bin/*" : " ./bin/*.js" ,
1819 "#http/*" : " ./app/http/*.js" ,
1920 "#models/*" : " ./app/models/*.js" ,
2021 "#services/*" : " ./app/services/*.js" ,
Original file line number Diff line number Diff line change 11import { ConfigurationLoader } from "../lib/configuration/configuration-loader.js" ;
2+ import { IntentCliFileTransformer } from "../lib/configuration/intent-cli.js" ;
23import { INTENT_CONFIG_FILE_NAME } from "../lib/constants.js" ;
34import { AssetsManager } from "../lib/dev-server/assets/assets-manager.js" ;
45import { defaultSwcOptionsFactory } from "../lib/dev-server/swc/default-options.js" ;
@@ -38,6 +39,9 @@ export class BuildCommand {
3839 const assetsManager = new AssetsManager ( ) ;
3940 await assetsManager . handle ( TS_CONFIG , INTENT_CONFIG ) ;
4041
42+ const intentCliFileTransformer = new IntentCliFileTransformer ( ) ;
43+ await intentCliFileTransformer . load ( TS_CONFIG ) ;
44+
4145 const SWC_OPTIONS = defaultSwcOptionsFactory ( TS_CONFIG , INTENT_CONFIG ) ;
4246 await this . swcFileTransformer . handle ( TS_CONFIG , INTENT_CONFIG , SWC_OPTIONS ) ;
4347 }
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import { INTENT_CONFIG_FILE_NAME } from "../lib/configuration/constant.js";
1212import fsExtra from "fs-extra" ;
1313import { DevServer } from "../lib/dev-server/dev-server.js" ;
1414import { AssetsManager } from "../lib/dev-server/assets/assets-manager.js" ;
15+ import { IntentCliFileTransformer } from "../lib/configuration/intent-cli.js" ;
1516
1617const { mkdirSync } = fsExtra ;
1718export class StartServerCommand {
@@ -45,6 +46,9 @@ export class StartServerCommand {
4546 { watch, debug, typeCheck : ! isTruthy ( disableTypeCheck ) }
4647 ) ;
4748
49+ const intentCliFileTransformer = new IntentCliFileTransformer ( ) ;
50+ await intentCliFileTransformer . load ( TS_CONFIG ) ;
51+
4852 const assetsManager = new AssetsManager ( ) ;
4953 const assetsOnUpdateHook = await assetsManager . handle (
5054 TS_CONFIG ,
Original file line number Diff line number Diff line change 1+ import { INTENT_LOG_PREFIX } from "../utils/log-helpers.js" ;
2+ import pc from "picocolors" ;
3+ import { SwcTransformer } from "../dev-server/swc/swc-transformer.js" ;
4+ import { ParsedCommandLine } from "typescript" ;
5+ import { INTENT_CLI_FILE } from "../constants.js" ;
6+ import { readFileSync , writeFileSync } from "fs" ;
7+
8+ export class IntentCliFileTransformer {
9+ private swcTransformer = new SwcTransformer ( ) ;
10+
11+ async load ( TS_CONFIG : ParsedCommandLine ) : Promise < void > {
12+ try {
13+ const tempIntentRcPath = await this . swcTransformer . transpileTemp (
14+ INTENT_CLI_FILE ,
15+ "intent" ,
16+ TS_CONFIG
17+ ) ;
18+
19+ const code = readFileSync ( tempIntentRcPath , "utf-8" ) ;
20+
21+ const newCode = code . replace (
22+ / i m p o r t \s + [ ' " ] @ i n t e n t j s \/ t s - n o d e \/ e s m [ ' " ] ; ? / g,
23+ ""
24+ ) ;
25+
26+ writeFileSync ( tempIntentRcPath , newCode ) ;
27+ } catch ( e ) {
28+ console . log ( e ) ;
29+ console . log ( INTENT_LOG_PREFIX , pc . red ( e . message ) ) ;
30+ process . exit ( ) ;
31+ }
32+ }
33+ }
Original file line number Diff line number Diff line change 11export const INTENT_CONFIG_FILE_NAME = "intentrc.ts" ;
22export const TSCONFIG_JSON = "tsconfig.json" ;
3+ export const INTENT_CLI_FILE = "intent" ;
Original file line number Diff line number Diff line change @@ -61,8 +61,9 @@ export class SwcFileTransformer {
6161 : codeFilePath ;
6262 writeFileSync ( osSpecificFilePath , code ) ;
6363
64- options . sourceMaps &&
64+ if ( options . sourceMaps ) {
6565 this . writeSourceMap ( isWindows , distFilePath , map ) ;
66+ }
6667
6768 resolve ( 1 ) ;
6869 } )
Original file line number Diff line number Diff line change 11{
22 "name" : " @intentjs/cli" ,
3- "version" : " 0.0.19 " ,
3+ "version" : " 0.0.21 " ,
44 "description" : " Helper commands for building Intent application." ,
55 "repository" : {
66 "type" : " git" ,
You can’t perform that action at this time.
0 commit comments