Skip to content

Commit

Permalink
Add ts-app-template
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Jul 27, 2022
1 parent a09c485 commit 28c0445
Show file tree
Hide file tree
Showing 35 changed files with 515 additions and 93 deletions.
5 changes: 5 additions & 0 deletions tests/scenarios/scenarios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,10 @@ export function baseApp() {
return Project.fromDir(dirname(require.resolve('../app-template/package.json')), { linkDevDeps: true });
}

export function baseTSApp() {
return Project.fromDir(dirname(require.resolve('../ts-app-template/package.json')), { linkDevDeps: true });
}

export const appScenarios = supportMatrix(Scenarios.fromProject(baseApp));
export const tsAppScenarios = supportMatrix(Scenarios.fromProject(baseTSApp));
export const dummyAppScenarios = supportMatrix(Scenarios.fromProject(() => baseAddon('dummy-app')));
98 changes: 5 additions & 93 deletions tests/scenarios/typescript-app-test.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,18 @@
import { appScenarios } from './scenarios';
import { tsAppScenarios } from './scenarios';
import { PreparedApp } from 'scenario-tester';
import QUnit from 'qunit';
import merge from 'lodash/merge';
const { module: Qmodule, test } = QUnit;

appScenarios
tsAppScenarios
.skip('lts_3_16')
.skip('lts_3_24')
.map('typescript-app', project => {
project.linkDevDependency('typescript', { baseDir: __dirname });
project.linkDevDependency('@tsconfig/ember', { baseDir: __dirname });
project.linkDevDependency('ember-cli-htmlbars', { baseDir: __dirname, resolveName: 'ember-cli-htmlbars-6' });

let app = project.files.app;
let tests = project.files.tests;

if (app && typeof app !== 'string') {
delete app['app.js'];
delete app['router.js'];
}

if (tests && typeof tests !== 'string') {
delete tests['test-helper.js']
}
// project.linkDevDependency('typescript', { baseDir: __dirname });
// project.linkDevDependency('@tsconfig/ember', { baseDir: __dirname });
// project.linkDevDependency('ember-cli-htmlbars', { baseDir: __dirname, resolveName: 'ember-cli-htmlbars-6' });

merge(project.files, {
'tsconfig.json': `
{
"extends": "@tsconfig/ember/tsconfig.json",
"paths": {
"app-template/tests/*": ["tests/*"],
"app-template/*": ["app/*"],
},
"include": ["app/**/*", "tests/**/*"]
}
`,
app: {
components: {
'incrementer.ts': `
Expand Down Expand Up @@ -62,47 +40,8 @@ appScenarios
</div>
`,
},
'router.ts': `
import EmberRouter from '@ember/routing/router';
import config from 'app-template/config/environment';
export default class Router extends EmberRouter {
location = config.locationType;
rootURL = config.rootURL;
}
Router.map(function() {});
`,
'app.ts': `
import Application from '@ember/application';
import Resolver from 'ember-resolver';
import loadInitializers from 'ember-load-initializers';
import config from './config/environment';
export default class App extends Application {
modulePrefix = config.modulePrefix;
podModulePrefix = config.podModulePrefix;
Resolver = Resolver;
}
loadInitializers(App, config.modulePrefix);
`,
},
tests: {
'test-helper.ts': `
import Application from 'app-template/app';
import config from 'app-template/config/environment';
import * as QUnit from 'qunit';
import { setApplication } from '@ember/test-helpers';
import { setup } from 'qunit-dom';
import { start } from 'ember-qunit';
setApplication(Application.create(config.APP));
setup(QUnit.assert);
start();
`,
rendering: {
'incrementer-test.ts': `
import { module, test } from 'qunit';
Expand All @@ -129,33 +68,6 @@ appScenarios
`,
},
},
'ember-cli-build.js': `
'use strict';
const EmberApp = require('ember-cli/lib/broccoli/ember-app');
module.exports = function (defaults) {
let app = new EmberApp(defaults, {
'ember-cli-babel': {
enableTypeScriptTransform: true,
},
});
const Webpack = require('@embroider/webpack').Webpack;
return require('@embroider/compat').compatBuild(app, Webpack, {
staticAddonTrees: true,
staticAddonTestSupportTrees: true,
staticHelpers: true,
staticModifiers: true,
staticComponents: true,
splitControllers: true,
splitRouteClasses: true,
skipBabel: [
{ package: 'qunit' },
],
});
};
`,
});
})
.forEachScenario(scenario => {
Expand Down
20 changes: 20 additions & 0 deletions tests/ts-app-template/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true


[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2

[*.hbs]
insert_final_newline = false

[*.{diff,md}]
trim_trailing_whitespace = false
9 changes: 9 additions & 0 deletions tests/ts-app-template/.ember-cli
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
/**
Ember CLI sends analytics information by default. The data is completely
anonymous, but there are times when you might want to disable this behavior.

Setting `disableAnalytics` to true will prevent any data from being sent.
*/
"disableAnalytics": false
}
20 changes: 20 additions & 0 deletions tests/ts-app-template/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# unconventional js
/blueprints/*/files/
/vendor/

# compiled output
/dist/
/tmp/

# dependencies
/bower_components/
/node_modules/

# misc
/coverage/
!.*

# ember-try
/.node_modules.ember-try/
/bower.json.ember-try
/package.json.ember-try
45 changes: 45 additions & 0 deletions tests/ts-app-template/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
'use strict';

module.exports = {
root: true,
parser: 'babel-eslint',
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
plugins: ['ember'],
extends: ['eslint:recommended', 'plugin:ember/recommended'],
env: {
browser: true,
},
rules: {},
overrides: [
// node files
{
files: [
'.eslintrc.js',
'.template-lintrc.js',
'ember-cli-build.js',
'testem.js',
'blueprints/*/index.js',
'config/**/*.js',
'lib/*/index.js',
'server/**/*.js',
],
parserOptions: {
sourceType: 'script',
},
env: {
browser: false,
node: true,
},
plugins: ['node'],
extends: ['plugin:node/recommended'],
rules: {
// this can be removed once the following is fixed
// https://github.com/mysticatea/eslint-plugin-node/issues/77
'node/no-unpublished-require': 'off',
},
},
],
};
25 changes: 25 additions & 0 deletions tests/ts-app-template/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist/
/tmp/

# dependencies
/bower_components/
/node_modules/

# misc
/.env*
/.pnp*
/.sass-cache
/connect.lock
/coverage/
/libpeerconnection.log
/npm-debug.log*
/testem.log
/yarn-error.log

# ember-try
/.node_modules.ember-try/
/bower.json.ember-try
/package.json.ember-try
5 changes: 5 additions & 0 deletions tests/ts-app-template/.template-lintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

module.exports = {
extends: 'octane',
};
3 changes: 3 additions & 0 deletions tests/ts-app-template/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"ignore_dirs": ["tmp", "dist"]
}
58 changes: 58 additions & 0 deletions tests/ts-app-template/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# ts-app-template

This README outlines the details of collaborating on this Ember application.
A short introduction of this app could easily go here.

## Prerequisites

You will need the following things properly installed on your computer.

* [Git](https://git-scm.com/)
* [Node.js](https://nodejs.org/)
* [Yarn](https://yarnpkg.com/)
* [Ember CLI](https://ember-cli.com/)
* [Google Chrome](https://google.com/chrome/)

## Installation

* `git clone <repository-url>` this repository
* `cd ts-app-template`
* `yarn install`

## Running / Development

* `ember serve`
* Visit your app at [http://localhost:4200](http://localhost:4200).
* Visit your tests at [http://localhost:4200/tests](http://localhost:4200/tests).

### Code Generators

Make use of the many generators for code, try `ember help generate` for more details

### Running Tests

* `ember test`
* `ember test --server`

### Linting

* `yarn lint:hbs`
* `yarn lint:js`
* `yarn lint:js --fix`

### Building

* `ember build` (development)
* `ember build --environment production` (production)

### Deploying

Specify what it takes to deploy your app.

## Further Reading / Useful Links

* [ember.js](https://emberjs.com/)
* [ember-cli](https://ember-cli.com/)
* Development Browser Extensions
* [ember inspector for chrome](https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi)
* [ember inspector for firefox](https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/)
12 changes: 12 additions & 0 deletions tests/ts-app-template/app/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Application from '@ember/application';
import Resolver from 'ember-resolver';
import loadInitializers from 'ember-load-initializers';
import config from 'ts-app-template/config/environment';

export default class App extends Application {
modulePrefix = config.modulePrefix;
podModulePrefix = config.podModulePrefix;
Resolver = Resolver;
}

loadInitializers(App, config.modulePrefix);
Empty file.
Empty file.
Empty file.
25 changes: 25 additions & 0 deletions tests/ts-app-template/app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<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="{{rootURL}}assets/vendor.css">
<link integrity="" rel="stylesheet" href="{{rootURL}}assets/ts-app-template.css">

{{content-for "head-footer"}}
</head>
<body>
{{content-for "body"}}

<script src="{{rootURL}}assets/vendor.js"></script>
<script src="{{rootURL}}assets/ts-app-template.js"></script>

{{content-for "body-footer"}}
</body>
</html>
Empty file.
9 changes: 9 additions & 0 deletions tests/ts-app-template/app/router.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import EmberRouter from '@ember/routing/router';
import config from 'ts-app-template/config/environment';

export default class Router extends EmberRouter {
location = config.locationType;
rootURL = config.rootURL;
}

Router.map(function () {});
Empty file.
Empty file.
1 change: 1 addition & 0 deletions tests/ts-app-template/app/templates/application.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{outlet}}
Loading

0 comments on commit 28c0445

Please sign in to comment.