-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from embroider-build/initial-version
Initial working version
- Loading branch information
Showing
10 changed files
with
5,972 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import globals from "globals"; | ||
import pluginJs from "@eslint/js"; | ||
|
||
|
||
export default [ | ||
{files: ["**/*.js"], languageOptions: {sourceType: "commonjs"}}, | ||
{languageOptions: { globals: globals.node }}, | ||
pluginJs.configs.recommended, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>AppTemplate</title> | ||
<meta name="description" content=""> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
|
||
{{content-for "head"}} | ||
|
||
<link integrity="" rel="stylesheet" href="/@embroider/core/vendor.css"> | ||
<link integrity="" rel="stylesheet" href="/assets/app-template.css"> | ||
|
||
{{content-for "head-footer"}} | ||
</head> | ||
<body> | ||
{{content-for "body"}} | ||
|
||
<script src="/@embroider/core/vendor.js"></script> | ||
<script src="/@embroider/core/entrypoint" type="module"></script> | ||
|
||
{{content-for "body-footer"}} | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
|
||
const EmberApp = require('ember-cli/lib/broccoli/ember-app'); | ||
const { maybeEmbroider } = require('@embroider/test-setup'); | ||
|
||
module.exports = function (defaults) { | ||
let app = new EmberApp(defaults, {}); | ||
|
||
return maybeEmbroider(app, { | ||
skipBabel: [ | ||
{ | ||
package: 'qunit', | ||
}, | ||
], | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>AppTemplate Tests</title> | ||
<meta name="description" content="" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
|
||
{{content-for "head"}} {{content-for "test-head"}} | ||
|
||
<link rel="stylesheet" href="/@embroider/core/vendor.css" /> | ||
<link rel="stylesheet" href="/assets/app-template.css" /> | ||
<link rel="stylesheet" href="/@embroider/core/test-support.css" /> | ||
|
||
{{content-for "head-footer"}} {{content-for "test-head-footer"}} | ||
</head> | ||
<body> | ||
{{content-for "body"}} {{content-for "test-body"}} | ||
|
||
<div id="qunit"></div> | ||
<div id="qunit-fixture"> | ||
<div id="ember-testing-container"> | ||
<div id="ember-testing"></div> | ||
</div> | ||
</div> | ||
|
||
<script src="/testem.js" integrity="" data-embroider-ignore></script> | ||
<script src="/@embroider/core/vendor.js"></script> | ||
<script src="/@embroider/core/test-support.js"></script> | ||
<script src="/@embroider/core/entrypoint" type="module"></script> | ||
<script src="/@embroider/core/test-entrypoint" type="module"></script> | ||
|
||
{{content-for "body-footer"}} {{content-for "test-body-footer"}} | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
let config; | ||
|
||
// TODO - remove this once we have the better solution for injecting stage1 babel config into a real config file | ||
// this is needed because there are things (like ember-composible-helpers) that are now finding our babel config during | ||
// their stage1 build and historically they will never (99% of the time) have found any babel config. | ||
// we might need to keep something like this so that prebuild will never apply babel configs during stage1 i.e. a util | ||
// function that wraps your whole babel config | ||
if ( | ||
process.env.EMBROIDER_PREBUILD || | ||
process.env.EMBROIDER_TEST_SETUP_FORCE === "classic" | ||
) { | ||
config = {}; | ||
} else { | ||
config = require("./node_modules/.embroider/_babel_config_"); | ||
} | ||
|
||
module.exports = config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { defineConfig } from "vite"; | ||
import { | ||
resolver, | ||
hbs, | ||
scripts, | ||
templateTag, | ||
optimizeDeps, | ||
compatPrebuild, | ||
assets, | ||
contentFor, | ||
} from "@embroider/vite"; | ||
import { resolve } from "path"; | ||
import { babel } from "@rollup/plugin-babel"; | ||
|
||
const root = "node_modules/.embroider/rewritten-app"; | ||
|
||
export default defineConfig(({ mode }) => { | ||
return { | ||
root, | ||
// esbuild in vite does not support decorators | ||
esbuild: false, | ||
cacheDir: resolve("node_modules", ".vite"), | ||
plugins: [ | ||
hbs(), | ||
templateTag(), | ||
scripts(), | ||
resolver(), | ||
compatPrebuild(), | ||
assets(), | ||
contentFor(), | ||
|
||
babel({ | ||
babelHelpers: "runtime", | ||
|
||
// this needs .hbs because our hbs() plugin above converts them to | ||
// javascript but the javascript still also needs babel, but we don't want | ||
// to rename them because vite isn't great about knowing how to hot-reload | ||
// them if we resolve them to made-up names. | ||
extensions: [".gjs", ".js", ".hbs", ".ts", ".gts"], | ||
}), | ||
], | ||
optimizeDeps: optimizeDeps(), | ||
publicDir: resolve(process.cwd(), "public"), | ||
server: { | ||
port: 4200, | ||
watch: { | ||
ignored: ["!**/node_modules/.embroider/rewritten-app/**"], | ||
}, | ||
}, | ||
build: { | ||
outDir: resolve(process.cwd(), "dist"), | ||
rollupOptions: { | ||
input: { | ||
main: resolve(root, "index.html"), | ||
...(shouldBuildTests(mode) | ||
? { tests: resolve(root, "tests/index.html") } | ||
: undefined), | ||
}, | ||
}, | ||
}, | ||
}; | ||
}); | ||
|
||
function shouldBuildTests(mode) { | ||
return mode !== "production" || process.env.FORCE_BUILD_TESTS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
const Blueprint = require('ember-cli/lib/models/blueprint'); | ||
const fs = require('fs-extra'); | ||
const { join } = require('path'); | ||
|
||
const appBlueprint = Blueprint.lookup('app'); | ||
|
||
module.exports = { | ||
locals(options) { | ||
return appBlueprint.locals(options); | ||
}, | ||
beforeInstall(options) { | ||
if (!appBlueprint) { | ||
throw new Error('Cannot find app blueprint for generating test-app!'); | ||
} | ||
|
||
return appBlueprint.install({ | ||
...options, | ||
skipGit: true, | ||
}); | ||
}, | ||
|
||
async afterInstall(options) { | ||
// there doesn't seem to be a way to tell ember-cli to not prompt to override files that were added in the beforeInstall | ||
// so I'm just copying a few over at this stage | ||
await fs.copy(join(__dirname, 'files-override'), options.target, { | ||
overwrite: true, | ||
}); | ||
|
||
// this.addPackagesToProject doesn't respect the packageManager that the blueprint specified 🙈 so we're skipping a level here | ||
let installTask = this.taskFor('npm-install'); | ||
await installTask.run({ | ||
'save-dev': true, | ||
verbose: false, | ||
packages: [ | ||
'@embroider/core@unstable', | ||
'@embroider/vite@unstable', | ||
'@embroider/compat@unstable', | ||
'@embroider/test-setup@unstable', | ||
'vite', | ||
'@rollup/plugin-babel' | ||
], | ||
packageManager: options.packageManager, | ||
}); | ||
|
||
let uninstallTask = this.taskFor('npm-uninstall'); | ||
await uninstallTask.run({ | ||
'save-dev': true, | ||
verbose: false, | ||
packages: ['ember-fetch'], | ||
packageManager: options.packageManager, | ||
}); | ||
|
||
let packageJson = join(options.target, 'package.json'); | ||
let json = await fs.readJSON(packageJson); | ||
|
||
json.scripts = { | ||
...json.scripts, | ||
"build": "vite build", | ||
"start": "vite", | ||
"test:ember": "vite build --mode test && ember test --path dist" | ||
}; | ||
|
||
await fs.writeFile(packageJson, JSON.stringify(json, null, 2)); | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "@embroider/app-blueprint", | ||
"version": "0.0.0", | ||
"description": "Blueprint for next generation of Ember apps", | ||
"main": "index.js", | ||
"scripts": { | ||
"lint": "eslint .", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"ember-cli": "^5.8.1", | ||
"fs-extra": "^11.2.0" | ||
}, | ||
"devDependencies": { | ||
"@eslint/js": "^9.3.0", | ||
"eslint": "9.x", | ||
"globals": "^15.3.0" | ||
} | ||
} |
Oops, something went wrong.