Skip to content

Commit

Permalink
$ mber new now transpiles tsconfig.json correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
izelnakri committed Feb 17, 2020
1 parent a56d25b commit e0193ea
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 20 deletions.
26 changes: 16 additions & 10 deletions ember-app-boilerplate/config/environment.ts
Original file line number Diff line number Diff line change
@@ -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;
}
10 changes: 8 additions & 2 deletions ember-app-boilerplate/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@
"module": "es6",
"experimentalDecorators": true,
"paths": {
"{{applicationName}}/tests/*": [
"{{applicationName}}}/tests/*": [
"tests/*"
],
"{{{applicationName}}}/config/*": [
"config/*"
],
"{{applicationName}}/*": [
"src/*"
],
Expand All @@ -33,8 +36,11 @@
}
},
"include": [
"app/**/*",
"src/**/*",
"tests/**/*",
"types/**/*"
],
"exclude": [
"node_modules/bip39"
]
}
17 changes: 9 additions & 8 deletions lib/commands/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -39,15 +38,17 @@ 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 ([
indexJSSource,
environmentSource,
packageSource,
testHTMLSource,
mberPackageJSON
mberPackageJSON,
tsConfigSource
]) => {
const packageVersion = JSON.parse(mberPackageJSON).version;

Expand All @@ -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' +
Expand All @@ -86,17 +91,13 @@ 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:`));
console.log(`$ cd ${applicationName} && npm install && mber s`);
});
})
.catch((error) => {
spinner.stop();

Console.error(error);
});
}

0 comments on commit e0193ea

Please sign in to comment.