Skip to content

Commit 3628755

Browse files
committed
chore(all): typescript conversion
Converts the plugin to typescript. Converts build tooling new aurelia-cli plugin support. Updates dependencies. BREAKING CHANGE: all
1 parent af49e15 commit 3628755

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+7744
-1455
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
jspm_packages
1+
.vscode
22
node_modules
3+
scripts
4+
timestamp.txt

aurelia_project/aurelia.json

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
{
2+
"name": "aurelia-routed-footer",
3+
"type": "project:plugin",
4+
"paths": {
5+
"root": "dev-app",
6+
"resources": "../src",
7+
"elements": "../src/elements",
8+
"attributes": "../src/attributes",
9+
"valueConverters": "../src/value-converters",
10+
"bindingBehaviors": "../src/binding-behaviors"
11+
},
12+
"transpiler": {
13+
"id": "typescript",
14+
"fileExtension": ".ts",
15+
"dtsSource": [
16+
"./types/**/*.d.ts"
17+
],
18+
"source": [
19+
"dev-app/**/*.ts",
20+
"src/**/*.ts"
21+
]
22+
},
23+
"plugin": {
24+
"source": {
25+
"js": "src/**/*.ts",
26+
"css": "src/**/*.scss",
27+
"html": "src/**/*.html",
28+
"json": "src/**/*.json"
29+
}
30+
},
31+
"markupProcessor": {
32+
"source": [
33+
"dev-app/**/*.html",
34+
"src/**/*.html"
35+
]
36+
},
37+
"cssProcessor": {
38+
"source": [
39+
"dev-app/**/*.scss",
40+
"src/**/*.scss"
41+
]
42+
},
43+
"jsonProcessor": {
44+
"source": [
45+
"dev-app/**/*.json",
46+
"src/**/*.json"
47+
]
48+
},
49+
"unitTestRunner": {
50+
"source": "test/unit/**/*.ts"
51+
},
52+
"testFramework": {
53+
"id": "jasmine"
54+
},
55+
"platform": {
56+
"port": 9000,
57+
"index": "index.html",
58+
"baseDir": ".",
59+
"output": "scripts"
60+
},
61+
"build": {
62+
"targets": [
63+
{
64+
"port": 9000,
65+
"index": "index.html",
66+
"baseDir": ".",
67+
"output": "scripts"
68+
}
69+
],
70+
"options": {
71+
"minify": "stage & prod",
72+
"sourcemaps": "dev & stage",
73+
"rev": false,
74+
"cache": "dev & stage"
75+
},
76+
"bundles": [
77+
{
78+
"name": "app-bundle.js",
79+
"source": [
80+
"**/*.{js,json,css,html}"
81+
]
82+
},
83+
{
84+
"name": "vendor-bundle.js",
85+
"prepend": [
86+
"node_modules/requirejs/require.js"
87+
],
88+
"dependencies": [
89+
"aurelia-bootstrapper",
90+
"aurelia-loader-default",
91+
"aurelia-pal-browser",
92+
{
93+
"name": "aurelia-testing",
94+
"env": "dev"
95+
},
96+
"text"
97+
]
98+
}
99+
],
100+
"loader": {
101+
"type": "require",
102+
"configTarget": "vendor-bundle.js",
103+
"includeBundleMetadataInConfig": "auto",
104+
"plugins": [
105+
{
106+
"name": "text",
107+
"extensions": [
108+
".html",
109+
".css"
110+
],
111+
"stub": false
112+
}
113+
]
114+
}
115+
},
116+
"packageManager": "yarn"
117+
}

aurelia_project/environments/dev.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default {
2+
debug: true,
3+
testing: true
4+
};

aurelia_project/environments/prod.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default {
2+
debug: false,
3+
testing: false
4+
};

aurelia_project/environments/stage.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default {
2+
debug: true,
3+
testing: false
4+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "attribute",
3+
"description": "Creates a custom attribute class and places it in the project resources."
4+
}
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import {inject} from 'aurelia-dependency-injection';
2+
import {Project, ProjectItem, CLIOptions, UI} from 'aurelia-cli';
3+
4+
@inject(Project, CLIOptions, UI)
5+
export default class AttributeGenerator {
6+
constructor(private project: Project, private options: CLIOptions, private ui: UI) { }
7+
8+
async execute() {
9+
const name = await this.ui.ensureAnswer(
10+
this.options.args[0],
11+
'What would you like to call the custom attribute?'
12+
);
13+
14+
let fileName = this.project.makeFileName(name);
15+
let className = this.project.makeClassName(name);
16+
17+
this.project.attributes.add(
18+
ProjectItem.text(`${fileName}.ts`, this.generateSource(className))
19+
);
20+
21+
await this.project.commitChanges();
22+
await this.ui.log(`Created ${fileName}.`);
23+
}
24+
25+
generateSource(className) {
26+
return `import {autoinject} from 'aurelia-framework';
27+
28+
@autoinject()
29+
export class ${className}CustomAttribute {
30+
constructor(private element: Element) { }
31+
32+
valueChanged(newValue, oldValue) {
33+
//
34+
}
35+
}
36+
`;
37+
}
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "binding-behavior",
3+
"description": "Creates a binding behavior class and places it in the project resources."
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import {inject} from 'aurelia-dependency-injection';
2+
import {Project, ProjectItem, CLIOptions, UI} from 'aurelia-cli';
3+
4+
@inject(Project, CLIOptions, UI)
5+
export default class BindingBehaviorGenerator {
6+
constructor(private project: Project, private options: CLIOptions, private ui: UI) { }
7+
8+
async execute() {
9+
const name = await this.ui.ensureAnswer(
10+
this.options.args[0],
11+
'What would you like to call the binding behavior?'
12+
);
13+
14+
let fileName = this.project.makeFileName(name);
15+
let className = this.project.makeClassName(name);
16+
17+
this.project.bindingBehaviors.add(
18+
ProjectItem.text(`${fileName}.ts`, this.generateSource(className))
19+
);
20+
21+
await this.project.commitChanges();
22+
await this.ui.log(`Created ${fileName}.`);
23+
}
24+
25+
generateSource(className) {
26+
return `export class ${className}BindingBehavior {
27+
bind(binding, source) {
28+
//
29+
}
30+
31+
unbind(binding, source) {
32+
//
33+
}
34+
}
35+
`
36+
}
37+
}
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "element",
3+
"description": "Creates a custom element class and template, placing them in the project resources."
4+
}

aurelia_project/generators/element.ts

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import {inject} from 'aurelia-dependency-injection';
2+
import {Project, ProjectItem, CLIOptions, UI} from 'aurelia-cli';
3+
4+
@inject(Project, CLIOptions, UI)
5+
export default class ElementGenerator {
6+
constructor(private project: Project, private options: CLIOptions, private ui: UI) { }
7+
8+
async execute() {
9+
const name = await this.ui.ensureAnswer(
10+
this.options.args[0],
11+
'What would you like to call the custom element?'
12+
);
13+
14+
let fileName = this.project.makeFileName(name);
15+
let className = this.project.makeClassName(name);
16+
17+
this.project.elements.add(
18+
ProjectItem.text(`${fileName}.ts`, this.generateJSSource(className)),
19+
ProjectItem.text(`${fileName}.html`, this.generateHTMLSource(className))
20+
);
21+
22+
await this.project.commitChanges();
23+
await this.ui.log(`Created ${fileName}.`);
24+
}
25+
26+
generateJSSource(className) {
27+
return `import {bindable} from 'aurelia-framework';
28+
29+
export class ${className} {
30+
@bindable value;
31+
32+
valueChanged(newValue, oldValue) {
33+
//
34+
}
35+
}
36+
`;
37+
}
38+
39+
generateHTMLSource(className) {
40+
return `<template>
41+
<h1>\${value}</h1>
42+
</template>
43+
`;
44+
}
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "generator",
3+
"description": "Creates a generator class and places it in the project generators folder."
4+
}
+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import {inject} from 'aurelia-dependency-injection';
2+
import {Project, ProjectItem, CLIOptions, UI} from 'aurelia-cli';
3+
4+
@inject(Project, CLIOptions, UI)
5+
export default class GeneratorGenerator {
6+
constructor(private project: Project, private options: CLIOptions, private ui: UI) { }
7+
8+
async execute() {
9+
const name = await this.ui.ensureAnswer(
10+
this.options.args[0],
11+
'What would you like to call the generator?'
12+
);
13+
14+
let fileName = this.project.makeFileName(name);
15+
let className = this.project.makeClassName(name);
16+
17+
this.project.generators.add(
18+
ProjectItem.text(`${fileName}.ts`, this.generateSource(className))
19+
);
20+
21+
await this.project.commitChanges()
22+
await this.ui.log(`Created ${fileName}.`);
23+
}
24+
25+
generateSource(className) {
26+
return `import {inject} from 'aurelia-dependency-injection';
27+
import {Project, ProjectItem, CLIOptions, UI} from 'aurelia-cli';
28+
29+
@inject(Project, CLIOptions, UI)
30+
export default class ${className}Generator {
31+
constructor(project, options, ui) {
32+
this.project = project;
33+
this.options = options;
34+
this.ui = ui;
35+
}
36+
37+
execute() {
38+
return this.ui
39+
.ensureAnswer(this.options.args[0], 'What would you like to call the new item?')
40+
.then(name => {
41+
let fileName = this.project.makeFileName(name);
42+
let className = this.project.makeClassName(name);
43+
44+
this.project.elements.add(
45+
ProjectItem.text(\`\${fileName}.ts\`, this.generateSource(className))
46+
);
47+
48+
return this.project.commitChanges()
49+
.then(() => this.ui.log(\`Created \${fileName}.\`));
50+
});
51+
}
52+
53+
generateSource(className) {
54+
return \`import {bindable} from 'aurelia-framework';
55+
56+
export class \${className} {
57+
@bindable value;
58+
59+
valueChanged(newValue, oldValue) {
60+
//
61+
}
62+
}
63+
\`
64+
}
65+
}
66+
`;
67+
}
68+
}

aurelia_project/generators/task.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "task",
3+
"description": "Creates a task and places it in the project tasks folder."
4+
}

aurelia_project/generators/task.ts

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import {inject} from 'aurelia-dependency-injection';
2+
import {Project, ProjectItem, CLIOptions, UI} from 'aurelia-cli';
3+
4+
@inject(Project, CLIOptions, UI)
5+
export default class TaskGenerator {
6+
constructor(private project: Project, private options: CLIOptions, private ui: UI) { }
7+
8+
async execute() {
9+
const name = await this.ui.ensureAnswer(
10+
this.options.args[0],
11+
'What would you like to call the task?'
12+
);
13+
14+
let fileName = this.project.makeFileName(name);
15+
let functionName = this.project.makeFunctionName(name);
16+
17+
this.project.tasks.add(
18+
ProjectItem.text(`${fileName}.ts`, this.generateSource(functionName))
19+
);
20+
21+
await this.project.commitChanges();
22+
await this.ui.log(`Created ${fileName}.`);
23+
}
24+
25+
generateSource(functionName) {
26+
return `import * as gulp from 'gulp';
27+
import * as project from '../aurelia.json';
28+
29+
export default function ${functionName}() {
30+
return gulp.src(project.paths.???)
31+
.pipe(gulp.dest(project.paths.output));
32+
}
33+
`;
34+
35+
}
36+
}

0 commit comments

Comments
 (0)