From e0193eab1bb4b1bdda0f5c4465b33a6592729f2c Mon Sep 17 00:00:00 2001 From: Izel Nakri Date: Mon, 17 Feb 2020 01:15:22 +0100 Subject: [PATCH] $ mber new now transpiles tsconfig.json correctly --- ember-app-boilerplate/config/environment.ts | 26 +++++++++++++-------- ember-app-boilerplate/tsconfig.json | 10 ++++++-- lib/commands/new.js | 17 +++++++------- 3 files changed, 33 insertions(+), 20 deletions(-) diff --git a/ember-app-boilerplate/config/environment.ts b/ember-app-boilerplate/config/environment.ts index 212099f4..79cd7507 100644 --- a/ember-app-boilerplate/config/environment.ts +++ b/ember-app-boilerplate/config/environment.ts @@ -1,16 +1,22 @@ export default config; -// Type declarations for - // import config from './config/environment' - -// For now these need to be managed by the developer -// since different ember addons can materialize new entries. +/** + * type declarations for + * import config from './config/environment' + * + * for now these need to be managed by the developer + * since different ember addons can materialize new entries. + */ declare const config: { - APP: any; + app: app; environment: any; - modulePrefix: string; - podModulePrefix: string; - locationType: string; - rootURL: string; + moduleprefix: string; + podmoduleprefix: string; + locationtype: string; + rooturl: string; + [propname: string]: any; }; +interface app { + [propname: string]: any; +} diff --git a/ember-app-boilerplate/tsconfig.json b/ember-app-boilerplate/tsconfig.json index 9545b52e..2d1e9e4c 100644 --- a/ember-app-boilerplate/tsconfig.json +++ b/ember-app-boilerplate/tsconfig.json @@ -21,9 +21,12 @@ "module": "es6", "experimentalDecorators": true, "paths": { - "{{applicationName}}/tests/*": [ + "{{applicationName}}}/tests/*": [ "tests/*" ], + "{{{applicationName}}}/config/*": [ + "config/*" + ], "{{applicationName}}/*": [ "src/*" ], @@ -33,8 +36,11 @@ } }, "include": [ - "app/**/*", + "src/**/*", "tests/**/*", "types/**/*" + ], + "exclude": [ + "node_modules/bip39" ] } diff --git a/lib/commands/new.js b/lib/commands/new.js index 8ce407b1..cfbd88c5 100755 --- a/lib/commands/new.js +++ b/lib/commands/new.js @@ -24,13 +24,12 @@ export default async function() { Console.log(`creating ${applicationName} application`); - let spinner = Console.spinner('Creating\n'); - const TARGET_DIRECTORY = `${CWD}/${applicationName}`; const ENVIRONMENT_PATH = `${TARGET_DIRECTORY}/config/environment.js`; const PACKAGE_JSON_PATH = `${TARGET_DIRECTORY}/package.json`; const TEST_HTML_PATH = `${TARGET_DIRECTORY}/tests/index.html`; const ENTRYPOINT_PATH = `${TARGET_DIRECTORY}/index.js`; + const TS_CONFIG_PATH = `${TARGET_DIRECTORY}/tsconfig.json`; await fs.copy(`${__dirname}/../../ember-app-boilerplate`, TARGET_DIRECTORY); @@ -39,7 +38,8 @@ export default async function() { fs.readFile(ENVIRONMENT_PATH), fs.readFile(PACKAGE_JSON_PATH), fs.readFile(TEST_HTML_PATH), - fs.readFile(`${__dirname}/../../package.json`) + fs.readFile(`${__dirname}/../../package.json`), + fs.readFile(TS_CONFIG_PATH) ]) .then( async ([ @@ -47,7 +47,8 @@ export default async function() { environmentSource, packageSource, testHTMLSource, - mberPackageJSON + mberPackageJSON, + tsConfigSource ]) => { const packageVersion = JSON.parse(mberPackageJSON).version; @@ -73,6 +74,10 @@ export default async function() { TEST_HTML_PATH, Mustache.render(testHTMLSource.toString(), { applicationName }) ), + fs.writeFile( + TS_CONFIG_PATH, + Mustache.render(tsConfigSource.toString(), { applicationName }) + ), fs.writeFile( `${TARGET_DIRECTORY}/.gitignore`, '.cache\n' + @@ -86,8 +91,6 @@ export default async function() { } ) .then(() => { - spinner.stop(); - fs.readdir(TARGET_DIRECTORY).then((fileAndFolders) => { fileAndFolders.forEach((fileOrFolder) => console.log(chalk.green('created'), fileOrFolder)); Console.log(chalk.green(`${applicationName} ember application created. Next is to do:`)); @@ -95,8 +98,6 @@ export default async function() { }); }) .catch((error) => { - spinner.stop(); - Console.error(error); }); }