Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_checkAddonAppFiles() {
// Emit a warning for addons that are under active development...
let isDevelopingAddon = !this.app && (this.parent as Addon).isDevelopingAddon();
// ...and are at the root of the project (i.e. not in-repo)...
let isRootAddon = this.parent.root === this.project.root;
// ...and have .ts files in their `app` directory.
let appDir = `${this.parent.root}/app`;
if (isDevelopingAddon && isRootAddon && fs.existsSync(appDir)) {
let tsFilesInApp = walkSync(appDir, { globs: ['**/*.ts'] });
if (tsFilesInApp.length) {
this.ui.writeWarnLine(
`found .ts files in ${appDir}\n` +
"ember-cli-typescript only compiles files in an addon's `addon` folder; " +
'see https://github.com/typed-ember/ember-cli-typescript/issues/562'
);
}
}
},
private writeAppJS(config: any) {
let mainModule = join(this.outputPath, this.app.isModuleUnification ? 'src/main' : 'app');
// standard JS file name, not customizable. It's not final anyway (that is
// up to the final stage packager). See also updateHTML in app.ts for where
// we're enforcing this in the HTML.
let appJS = join(this.outputPath, `assets/${this.app.name}.js`);
// for the app tree, we take everything
let lazyModules = walkSync(this.inputPaths[1], {
globs: ['**/*.{js,hbs}'],
ignore: ['tests/**'],
directories: false
}).map(specifier => {
let noJS = specifier.replace(/\.js$/, '');
let noHBS = noJS.replace(/\.hbs$/, '');
return {
runtime: `${config.modulePrefix}/${noHBS}`,
buildtime: `../${noJS}`
};
});
// for the src tree, we can limit ourselves to only known resolvable
// collections
todo("app src tree");
registerDir(dirpath, typeName) {
let paths = walk(dirpath);
paths.forEach((filepath) => {
let absolutepath = path.join(dirpath, filepath);
let moduleName = filepath.replace(JS_EXT, '');
if (fs.statSync(absolutepath).isFile() && JS_EXT.test(absolutepath)) {
this.register(typeName + '/' + moduleName, require(absolutepath));
}
});
},
export default (folder, globs) => globs ?
walkSync(folder, { globs: ensureArray(globs) }) : [folder];
files() {
if (this._files) {
return this._files;
}
let filesPath = this.filesPath();
if (fileExists(filesPath)) {
this._files = walkSync(filesPath);
} else {
this._files = [];
}
return this._files;
}
generate({ params, flags }) {
let data = this.locals(params, flags);
let dest = process.cwd();
walk(this.templateFiles).forEach((relativepath) => {
let absolutepath = path.resolve(path.join(this.templateFiles, relativepath));
if (isDir(absolutepath)) {
return null;
}
let filenameTemplate = template(relativepath, {
interpolate: /__([\S]+)__/g,
sourceURL: relativepath
});
let destRelativepath = filenameTemplate(data);
let destAbsolutepath = path.join(dest, destRelativepath);
if (fs.existsSync(destAbsolutepath)) {
return ui.info(`${ chalk.green('already exists') } ${ destRelativepath }`);
}
pathRoots: string[],
destDir: string,
physicalPaths: string[]
) {
for (let pathRoot of pathRoots) {
for (let physicalPath of physicalPaths) {
if (!physicalPath.endsWith('/*')) {
throw new Error(`Missing trailing '*' in path mapping: ${physicalPath}`);
}
let fullRoot = path.resolve(pathRoot, physicalPath.replace(/\/\*$/, ''));
if (!fs.existsSync(fullRoot)) {
continue;
}
for (let file of walkSync(fullRoot, { globs: ['**/*.d.ts'] })) {
let destinationPath = path.join(destDir, file);
if (!fs.existsSync(destinationPath)) {
copyFile(output, path.join(fullRoot, file), destinationPath);
}
}
}
}
}
addonTestSupportTree = new ObserveTree(addonTestSupportTree, outputPath => {
filenames = walkSync(outputPath, { globs: ['**/*.js', '**/*.hbs'] }).map(f => `./${f.replace(/.js$/i, '')}`);
});
built.dynamicMeta.push(() => ({
files() {
if (this._files) { return this._files; }
let filesPath = this.filesPath();
if (fileExists(filesPath)) {
this._files = walkSync(filesPath);
} else {
this._files = [];
}
return this._files;
}