Skip to content

Commit a448400

Browse files
committed
wip
1 parent 09cefc4 commit a448400

File tree

3 files changed

+165
-7
lines changed

3 files changed

+165
-7
lines changed

files/package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "<%= name %>",
3-
"version": "0.0.0",
3+
"version": "0.0.0",<% if (minimal) { %>
4+
"type": "module",<% } %>
45
"private": true,
56
"description": "Small description for <%= name %> goes here",
67
"repository": "",
@@ -52,8 +53,8 @@
5253
"@ember/test-waiters": "^4.1.0",
5354
"@embroider/macros": "^1.18.0",
5455
"@embroider/core": "^4.1.0",
55-
"@embroider/vite": "^1.1.5",
56-
"@embroider/compat": "^4.1.0",
56+
"@embroider/vite": "^1.1.5",<% if (!minimal) { %>
57+
"@embroider/compat": "^4.1.0",<% } %>
5758
"@embroider/router": "^3.0.1",
5859
"@embroider/config-meta-loader": "^1.0.0",
5960
"@eslint/js": "^9.27.0",
@@ -69,13 +70,13 @@
6970
"@warp-drive/ember": "~5.5.0<% } %>",
7071
"babel-plugin-ember-template-compilation": "^2.4.1",
7172
"concurrently": "^9.1.2",
72-
"decorator-transforms": "^2.3.0",
73+
"decorator-transforms": "^2.3.0",<% if (!minimal) {
7374
"ember-auto-import": "^2.10.0",
7475
"ember-cli": "~6.5.0-beta.0",
75-
"ember-cli-babel": "^8.2.0",
76+
"ember-cli-babel": "^8.2.0",<% } %>
7677
"ember-cli-deprecation-workflow": "^3.3.0<% if (emberData) { %>",
77-
"ember-data": "~5.5.0<% } %>",
78-
"ember-load-initializers": "^3.0.1",
78+
"ember-data": "~5.5.0<% } %>",<% if (!minimal) { %>
79+
"ember-load-initializers": "^3.0.1",<% } %>
7980
"ember-modifier": "^4.2.2",
8081
"ember-page-title": "^9.0.2",
8182
"ember-qunit": "^9.0.3",

index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ module.exports = {
3939
options.packageManager === 'pnpm' && '"--pnpm"',
4040
options.ciProvider && `"--ci-provider=${options.ciProvider}"`,
4141
options.typescript && `"--typescript"`,
42+
options.minimal && `"--minimal"`,
4243
!options.emberData && `"--no-ember-data"`,
4344
]
4445
.filter(Boolean)
@@ -64,6 +65,7 @@ module.exports = {
6465
name,
6566
modulePrefix: name,
6667
namespace,
68+
minimal: options.minimal,
6769
blueprintVersion: require('./package').version,
6870
yarn: options.packageManager === 'yarn',
6971
pnpm: options.packageManager === 'pnpm',
@@ -106,6 +108,15 @@ module.exports = {
106108
files = files.filter((file) => !file.includes('ember-data/'));
107109
}
108110

111+
if (options.minimal) {
112+
files = files.filter((file) => {
113+
return (
114+
!file.includes('ember-cli-build.js') &&
115+
!file.includes('environment.js')
116+
);
117+
});
118+
}
119+
109120
this._files = files;
110121

111122
return this._files;

tests/minimal.test.mjs

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
import { describe, it, expect } from 'vitest';
2+
import { join } from 'path';
3+
import { existsSync, writeFileSync } from 'fs';
4+
import stripAnsi from 'strip-ansi';
5+
import { newProjectWithFixtures } from './helpers.mjs';
6+
7+
const SCENARIOS = [
8+
{
9+
name: 'defaults',
10+
flags: ['--minimal'],
11+
fixturePath: join(import.meta.dirname, 'fixture-gjs-only'),
12+
},
13+
{
14+
name: 'typescript',
15+
flags: ['--typescript', '--minimal'],
16+
fixturePath: join(import.meta.dirname, 'fixture-gts-only'),
17+
},
18+
];
19+
20+
describe('basic functionality', function () {
21+
for (let { name, flags, packageJson, fixturePath } of SCENARIOS) {
22+
describe(name, function () {
23+
let project = newProjectWithFixtures({
24+
fixturePath,
25+
flags,
26+
packageJson,
27+
});
28+
29+
it('verify files', async function () {
30+
expect(
31+
!existsSync(join(project.dir(), 'app/index.html')),
32+
'the app index.html has been removed',
33+
);
34+
expect(
35+
existsSync(join(project.dir(), 'index.html')),
36+
'the root index.html has been added',
37+
);
38+
});
39+
40+
it('successfully lints', async function () {
41+
let result = await project.execa('pnpm', ['lint']);
42+
43+
console.log(result.stdout);
44+
});
45+
46+
it('successfully builds', async function () {
47+
let result = await project.execa('pnpm', ['build']);
48+
49+
console.log(result.stdout);
50+
});
51+
52+
it('successfully runs tests', async function () {
53+
let result;
54+
55+
try {
56+
result = await project.execa('pnpm', ['test']);
57+
} catch (err) {
58+
console.log(err.stdout, err.stderr);
59+
throw 'Failed to successfully run test';
60+
}
61+
62+
// make sure that each of the tests that we expect actually show up
63+
// alternatively we can change this to search for `pass 3`
64+
expect(result.stdout).to.contain(
65+
'Acceptance | welcome page: visiting /index shows the welcome page',
66+
);
67+
expect(result.stdout).to.contain(
68+
'Acceptance | styles: visiting /styles',
69+
);
70+
71+
console.log(result.stdout);
72+
});
73+
74+
it('successfully runs tests in dev mode', async function () {
75+
await project.$`pnpm install --save-dev testem http-proxy`;
76+
let appURL;
77+
78+
let server;
79+
80+
try {
81+
server = project.execa('pnpm', ['start']);
82+
83+
await new Promise((resolve) => {
84+
server.stdout.on('data', (line) => {
85+
let result = /Local:\s+(https?:\/\/.*)\//g.exec(
86+
stripAnsi(line.toString()),
87+
);
88+
89+
if (result) {
90+
appURL = result[1];
91+
resolve();
92+
}
93+
});
94+
});
95+
96+
writeFileSync(
97+
join(project.dir(), 'testem-dev.js'),
98+
`module.exports = {
99+
test_page: 'tests/index.html?hidepassed',
100+
disable_watching: true,
101+
launch_in_ci: ['Chrome'],
102+
launch_in_dev: ['Chrome'],
103+
browser_start_timeout: 120,
104+
browser_args: {
105+
Chrome: {
106+
ci: [
107+
// --no-sandbox is needed when running Chrome inside a container
108+
process.env.CI ? '--no-sandbox' : null,
109+
'--headless',
110+
'--disable-dev-shm-usage',
111+
'--disable-software-rasterizer',
112+
'--mute-audio',
113+
'--remote-debugging-port=0',
114+
'--window-size=1440,900',
115+
].filter(Boolean),
116+
},
117+
},
118+
middleware: [
119+
require(__dirname + '/testem-proxy.js')('${appURL}')
120+
],
121+
};
122+
`,
123+
);
124+
125+
let testResult = await project.execa('pnpm', [
126+
'testem',
127+
'--file',
128+
'testem-dev.js',
129+
'ci',
130+
]);
131+
expect(testResult.exitCode).to.eq(0, testResult.output);
132+
} finally {
133+
server?.kill('SIGINT');
134+
}
135+
});
136+
137+
it('successfully optimizes deps', function () {
138+
return project.execa('pnpm', ['vite', 'optimize', '--force']);
139+
});
140+
141+
it('can run generators', function () {
142+
return project.execa('pnpm', ['ember', 'g', 'route', 'fancy']);
143+
});
144+
});
145+
}
146+
});

0 commit comments

Comments
 (0)