Skip to content

Commit

Permalink
Fix types, since things moved around a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Oct 4, 2024
1 parent e5f5a37 commit 5087032
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 10 deletions.
2 changes: 1 addition & 1 deletion files-override/ts/app/app.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Application from '@ember/application';
import compatModules from '@embroider/virtual/entrypoint';
import compatModules from '@embroider/virtual/compat-modules';
import Resolver from 'ember-resolver';
import loadInitializers from 'ember-load-initializers';
import config from './config/environment';
Expand Down
3 changes: 1 addition & 2 deletions files-override/ts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"extends": "@tsconfig/ember/tsconfig.json",
"include": [
"app/**/*",
"tests/**/*",
"app", "tests", "types"
],
"glint": {
"environment": [
Expand Down
1 change: 1 addition & 0 deletions files-override/ts/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="@embroider/core/virtual" />
40 changes: 33 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,19 @@ const fs = require('fs');
const { join } = require('path');
const emberCliUpdate = require('./lib/ember-cli-update');
const copyWithTemplate = require('./lib/copy-with-template');
const { rm, readFile } = require('fs/promises');
const { rm, rmdir, readFile, lstat } = require('fs/promises');

const appBlueprint = Blueprint.lookup('app');

async function isDirectory(path) {
try {
let stat = await lstat(path);
return stat.isDirectory();
} catch (e) {

Check failure on line 14 in index.js

View workflow job for this annotation

GitHub Actions / Lint

'e' is defined but never used
return false;
}
}

module.exports = {
locals(options) {
return appBlueprint.locals(options);
Expand Down Expand Up @@ -171,22 +180,39 @@ module.exports = {
'.eslintignore',
// replaced with .prettierrc.cjs
'.prettierrc.js',
// We don't set up a template-registry, because we can be entirely gjs/gts
// TODO: when using the --compatibility flag (to be implemented), don't remove
// this folder
'types',
// ember-data / warp-drive doesn't want folks using models
'app/models',
'app/models/.gitkeep',
// If folks are using models, they have this file.
// New projects should not be using it though
// 'types/ember-data/types/registries/model.d.ts',
'types/global.d.ts',

// We don't need these with gjs/gts
'app/helpers/.gitkeep',

// Delete if empty, kept otherwise
'app/models',
'app/helpers',
];

// TODO: we should probably keep this because enabling TS for JS dev
// is actually very nice.
// Only difference would be that we don't have a lint:types
// or in-editor type-checking
if (!options.typescript) {
filesToDelete.push('tsconfig.json');
}

for (let file of filesToDelete) {
await rm(join(options.target, file), { recursive: true, force: true });
let targetFile = join(options.target, file);

let isDir = await isDirectory(targetFile);

if (isDir) {
await rmdir(targetFile);
} else {
await rm(targetFile);
}
}

// there doesn't seem to be a way to tell ember-cli to not prompt to override files that were added in the beforeInstall
Expand Down

0 comments on commit 5087032

Please sign in to comment.