@abcnews/aunty 16.0.1 → 17.0.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -160
- package/package.json +39 -82
- package/src/bin/aunty.ts +60 -0
- package/assets/done.mp3 +0 -0
- package/scripts/postinstall.js +0 -44
- package/src/api/index.js +0 -5
- package/src/bin/aunty.js +0 -27
- package/src/cli/build/constants.js +0 -46
- package/src/cli/build/index.js +0 -100
- package/src/cli/clean/constants.js +0 -10
- package/src/cli/clean/index.js +0 -40
- package/src/cli/constants.js +0 -114
- package/src/cli/deploy/constants.js +0 -40
- package/src/cli/deploy/index.js +0 -151
- package/src/cli/generate/constants.js +0 -39
- package/src/cli/generate/index.js +0 -72
- package/src/cli/index.js +0 -154
- package/src/cli/release/constants.js +0 -67
- package/src/cli/release/index.js +0 -162
- package/src/cli/serve/constants.js +0 -33
- package/src/cli/serve/index.js +0 -128
- package/src/cli/sign-cert/constants.js +0 -42
- package/src/cli/sign-cert/index.js +0 -50
- package/src/cli/test/constants.js +0 -15
- package/src/cli/test/index.js +0 -30
- package/src/config/babel.js +0 -75
- package/src/config/build.js +0 -39
- package/src/config/deploy.js +0 -143
- package/src/config/jest/index.js +0 -20
- package/src/config/jest/transformer-default.js +0 -27
- package/src/config/jest/transformer-svelte-preprocess.js +0 -8
- package/src/config/jest/transformer-svelte.js +0 -32
- package/src/config/project.js +0 -57
- package/src/config/serve.js +0 -144
- package/src/config/webpack.js +0 -325
- package/src/config/webpackDevServer.js +0 -46
- package/src/constants.js +0 -7
- package/src/generators/component/index.js +0 -172
- package/src/generators/component/templates/_non_sfc/styles.scss +0 -6
- package/src/generators/component/templates/basic/component-with-d3.test.ts +0 -7
- package/src/generators/component/templates/basic/component-with-d3.ts +0 -30
- package/src/generators/component/templates/basic/component.test.ts +0 -7
- package/src/generators/component/templates/basic/component.ts +0 -11
- package/src/generators/component/templates/preact/component-with-d3.test.tsx +0 -16
- package/src/generators/component/templates/preact/component-with-d3.tsx +0 -45
- package/src/generators/component/templates/preact/component.test.tsx +0 -18
- package/src/generators/component/templates/preact/component.tsx +0 -14
- package/src/generators/component/templates/react/component-with-d3.test.tsx +0 -13
- package/src/generators/component/templates/react/component-with-d3.tsx +0 -44
- package/src/generators/component/templates/react/component.test.tsx +0 -13
- package/src/generators/component/templates/react/component.tsx +0 -14
- package/src/generators/component/templates/svelte/component-with-d3.svelte +0 -46
- package/src/generators/component/templates/svelte/component-with-d3.test.ts +0 -10
- package/src/generators/component/templates/svelte/component.svelte +0 -17
- package/src/generators/component/templates/svelte/component.test.ts +0 -10
- package/src/generators/project/index.js +0 -244
- package/src/generators/project/templates/_common/.editorconfig +0 -12
- package/src/generators/project/templates/_common/.prettierrc +0 -6
- package/src/generators/project/templates/_common/LICENSE +0 -21
- package/src/generators/project/templates/_common/README.md +0 -3
- package/src/generators/project/templates/_common/_.gitignore +0 -12
- package/src/generators/project/templates/_common/package.json +0 -18
- package/src/generators/project/templates/_common/public/index.html +0 -21
- package/src/generators/project/templates/_common/src/components/Worm/worm.svg +0 -4
- package/src/generators/project/templates/_common/tsconfig.json +0 -4
- package/src/generators/project/templates/_non_sfc/src/components/App/styles.scss +0 -23
- package/src/generators/project/templates/_non_sfc/src/components/ErrorBox/styles.scss +0 -16
- package/src/generators/project/templates/_non_sfc/src/components/Worm/styles.scss +0 -4
- package/src/generators/project/templates/basic/src/components/App/index.test.ts +0 -9
- package/src/generators/project/templates/basic/src/components/App/index.ts +0 -22
- package/src/generators/project/templates/basic/src/components/ErrorBox/index.ts +0 -24
- package/src/generators/project/templates/basic/src/components/Worm/index.test.ts +0 -7
- package/src/generators/project/templates/basic/src/components/Worm/index.ts +0 -12
- package/src/generators/project/templates/basic/src/index.ts +0 -50
- package/src/generators/project/templates/preact/src/components/App/index.test.tsx +0 -21
- package/src/generators/project/templates/preact/src/components/App/index.tsx +0 -21
- package/src/generators/project/templates/preact/src/components/ErrorBox/index.tsx +0 -15
- package/src/generators/project/templates/preact/src/components/Worm/index.test.tsx +0 -14
- package/src/generators/project/templates/preact/src/components/Worm/index.tsx +0 -9
- package/src/generators/project/templates/preact/src/index.tsx +0 -42
- package/src/generators/project/templates/react/src/components/App/index.test.tsx +0 -14
- package/src/generators/project/templates/react/src/components/App/index.tsx +0 -21
- package/src/generators/project/templates/react/src/components/ErrorBox/index.tsx +0 -14
- package/src/generators/project/templates/react/src/components/Worm/index.test.tsx +0 -13
- package/src/generators/project/templates/react/src/components/Worm/index.tsx +0 -9
- package/src/generators/project/templates/react/src/index.tsx +0 -40
- package/src/generators/project/templates/svelte/src/components/App/App.svelte +0 -37
- package/src/generators/project/templates/svelte/src/components/App/App.test.ts +0 -18
- package/src/generators/project/templates/svelte/src/components/Worm/Worm.svelte +0 -12
- package/src/generators/project/templates/svelte/src/components/Worm/Worm.test.ts +0 -16
- package/src/generators/project/templates/svelte/src/index.ts +0 -26
- package/src/utils/async.js +0 -13
- package/src/utils/audio.js +0 -30
- package/src/utils/branding.js +0 -57
- package/src/utils/color.js +0 -12
- package/src/utils/ftp.js +0 -80
- package/src/utils/git.js +0 -127
- package/src/utils/logging.js +0 -74
- package/src/utils/npm.js +0 -59
- package/src/utils/remote.js +0 -81
- package/src/utils/structures.js +0 -33
- package/src/utils/text.js +0 -64
- package/ts/config.json +0 -22
- package/ts/custom.d.ts +0 -120
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { h } from 'preact';
|
|
2
|
-
import render from 'preact-render-to-string';
|
|
3
|
-
import htmlLooksLike from 'html-looks-like';
|
|
4
|
-
|
|
5
|
-
import <%= className %> from '.';
|
|
6
|
-
|
|
7
|
-
describe('<%= className %>', () => {
|
|
8
|
-
test('It renders', () => {
|
|
9
|
-
const actual = render(<<%= className %> />);
|
|
10
|
-
const expected = `
|
|
11
|
-
<div>
|
|
12
|
-
Find me in {{ ... }}
|
|
13
|
-
</div>
|
|
14
|
-
`;
|
|
15
|
-
|
|
16
|
-
htmlLooksLike(actual, expected);
|
|
17
|
-
});
|
|
18
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { h<% if (isTS) { %>, FunctionalComponent<% } %> } from 'preact';
|
|
2
|
-
import styles from './styles.scss';
|
|
3
|
-
<% if (isTS) { %>
|
|
4
|
-
type <%= className %>Props = {}
|
|
5
|
-
<% } %>
|
|
6
|
-
const <%= className %><% if (isTS) { %>: FunctionalComponent<<%= className %>Props><% } %> = () => {
|
|
7
|
-
return (
|
|
8
|
-
<div className={styles.root}>
|
|
9
|
-
Find me in <strong>src/components/<%= className %></strong>
|
|
10
|
-
</div>
|
|
11
|
-
);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export default <%= className %>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import renderer from 'react-test-renderer';
|
|
3
|
-
|
|
4
|
-
import <%= className %> from '.';
|
|
5
|
-
|
|
6
|
-
describe('<%= className %>', () => {
|
|
7
|
-
test('It renders', () => {
|
|
8
|
-
const component = renderer.create(<<%= className %> />);
|
|
9
|
-
|
|
10
|
-
let tree = component.toJSON();
|
|
11
|
-
expect(tree).toMatchSnapshot();
|
|
12
|
-
});
|
|
13
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { select<% if (isTS) { %>, Selection<% } %> } from 'd3-selection';
|
|
2
|
-
import React, { useEffect, useRef } from 'react';
|
|
3
|
-
import styles from './styles.scss';
|
|
4
|
-
<% if (isTS) { %>
|
|
5
|
-
type <%= className %>Props = {
|
|
6
|
-
color?: string;
|
|
7
|
-
}
|
|
8
|
-
<% } %>
|
|
9
|
-
const <%= className %><% if (isTS) { %>: React.FC<<%= className %>Props><% } %> = ({ color = 'black' }) => {
|
|
10
|
-
const root = useRef<% if (isTS) { %><HTMLDivElement | null><% } %>(null);
|
|
11
|
-
const svg = useRef<% if (isTS) { %><Selection<SVGSVGElement, unknown, null, undefined> | null><% } %>(null);
|
|
12
|
-
const g = useRef<% if (isTS) { %><Selection<SVGGElement, unknown, null, undefined> | null><% } %>(null);
|
|
13
|
-
const rect = useRef<% if (isTS) { %><Selection<SVGRectElement, unknown, null, undefined> | null><% } %>(null);
|
|
14
|
-
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
svg.current = select(root.current)
|
|
17
|
-
.append('svg')
|
|
18
|
-
.attr('width', 400)
|
|
19
|
-
.attr('height', 300);
|
|
20
|
-
|
|
21
|
-
g.current = svg.current.append('g');
|
|
22
|
-
|
|
23
|
-
rect.current = g.current
|
|
24
|
-
.append('rect')
|
|
25
|
-
.attr('x', 0)
|
|
26
|
-
.attr('y', 0)
|
|
27
|
-
.attr('rx', 3)
|
|
28
|
-
.attr('ry', 3)
|
|
29
|
-
.attr('width', '100%')
|
|
30
|
-
.attr('height', '100%');
|
|
31
|
-
}, []);
|
|
32
|
-
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
if (!g.current) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
g.current.attr('fill', color);
|
|
39
|
-
}, [color]);
|
|
40
|
-
|
|
41
|
-
return <div ref={root} className={styles.root}></div>;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export default <%= className %>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import renderer from 'react-test-renderer';
|
|
3
|
-
|
|
4
|
-
import <%= className %> from '.';
|
|
5
|
-
|
|
6
|
-
describe('<%= className %>', () => {
|
|
7
|
-
test('It renders', () => {
|
|
8
|
-
const component = renderer.create(<<%= className %> />);
|
|
9
|
-
|
|
10
|
-
let tree = component.toJSON();
|
|
11
|
-
expect(tree).toMatchSnapshot();
|
|
12
|
-
});
|
|
13
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import styles from './styles.scss';
|
|
3
|
-
<% if (isTS) { %>
|
|
4
|
-
type <%= className %>Props = {}
|
|
5
|
-
<% } %>
|
|
6
|
-
const <%= className %><% if (isTS) { %>: React.FC<<%= className %>Props><% } %> = () => {
|
|
7
|
-
return (
|
|
8
|
-
<div className={styles.root}>
|
|
9
|
-
Find me in <strong>src/components/<%= className %></strong>
|
|
10
|
-
</div>
|
|
11
|
-
);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export default <%= className %>;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
<script<% if (isTS) { %> lang="ts"<% } %>>
|
|
2
|
-
export let color<% if (isTS) { %>: string<% } %> = 'black';
|
|
3
|
-
|
|
4
|
-
import { select } from 'd3-selection';<% if (isTS) { %>
|
|
5
|
-
import type { Selection } from 'd3-selection';<% } %>
|
|
6
|
-
import { afterUpdate, onMount } from 'svelte';
|
|
7
|
-
|
|
8
|
-
let root<% if (isTS) { %>: HTMLDivElement<% } %>;
|
|
9
|
-
let svg<% if (isTS) { %>: Selection<SVGSVGElement, unknown, null, undefined><% } %>;
|
|
10
|
-
let g<% if (isTS) { %>: Selection<SVGGElement, unknown, null, undefined><% } %>;
|
|
11
|
-
let rect<% if (isTS) { %>: Selection<SVGRectElement, unknown, null, undefined><% } %>;
|
|
12
|
-
|
|
13
|
-
onMount(() => {
|
|
14
|
-
svg = select(root)
|
|
15
|
-
.append('svg')
|
|
16
|
-
.attr('width', 400)
|
|
17
|
-
.attr('height', 300);
|
|
18
|
-
|
|
19
|
-
g = svg.append('g').attr('fill', color);
|
|
20
|
-
|
|
21
|
-
rect = g
|
|
22
|
-
.append('rect')
|
|
23
|
-
.attr('x', 0)
|
|
24
|
-
.attr('y', 0)
|
|
25
|
-
.attr('rx', 3)
|
|
26
|
-
.attr('ry', 3)
|
|
27
|
-
.attr('width', '100%')
|
|
28
|
-
.attr('height', '100%');
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
afterUpdate(() => {
|
|
32
|
-
g.attr('fill', color);
|
|
33
|
-
});
|
|
34
|
-
</script>
|
|
35
|
-
|
|
36
|
-
<div bind:this={root} />
|
|
37
|
-
|
|
38
|
-
<style lang="scss">
|
|
39
|
-
div {
|
|
40
|
-
border: 1px solid rgb(255, 115, 0);
|
|
41
|
-
padding: 20px;
|
|
42
|
-
text-align: center;
|
|
43
|
-
color: black;
|
|
44
|
-
}
|
|
45
|
-
</style>
|
|
46
|
-
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { render } from '@testing-library/svelte'
|
|
2
|
-
import <%= className %> from './<%= className %>.svelte';
|
|
3
|
-
|
|
4
|
-
describe('<%= className %>', () => {
|
|
5
|
-
it('renders a snapshot', () => {
|
|
6
|
-
const { container } = render(<%= className %>);
|
|
7
|
-
|
|
8
|
-
expect(container).toMatchSnapshot();
|
|
9
|
-
});
|
|
10
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<script<% if (isTS) { %> lang="ts"<% } %>>
|
|
2
|
-
|
|
3
|
-
</script>
|
|
4
|
-
|
|
5
|
-
<div>
|
|
6
|
-
Find me in
|
|
7
|
-
<strong>src/components/<%= className %></strong>
|
|
8
|
-
</div>
|
|
9
|
-
|
|
10
|
-
<style lang="scss">
|
|
11
|
-
div {
|
|
12
|
-
border: 1px solid rgb(255, 115, 0);
|
|
13
|
-
padding: 20px;
|
|
14
|
-
text-align: center;
|
|
15
|
-
color: black;
|
|
16
|
-
}
|
|
17
|
-
</style>
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { render } from '@testing-library/svelte'
|
|
2
|
-
import <%= className %> from './<%= className %>.svelte';
|
|
3
|
-
|
|
4
|
-
describe('<%= className %>', () => {
|
|
5
|
-
it('renders a snapshot', () => {
|
|
6
|
-
const { container } = render(<%= className %>);
|
|
7
|
-
|
|
8
|
-
expect(container).toMatchSnapshot();
|
|
9
|
-
});
|
|
10
|
-
});
|
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
// Native
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
// External
|
|
5
|
-
const getAllPaths = require('get-all-paths');
|
|
6
|
-
const makeDir = require('make-dir');
|
|
7
|
-
const requireg = require('requireg');
|
|
8
|
-
const Generator = require('yeoman-generator');
|
|
9
|
-
const { to: wrap } = require('await-to-js');
|
|
10
|
-
const importLazy = require('import-lazy')(require);
|
|
11
|
-
|
|
12
|
-
// Ours
|
|
13
|
-
const { OUTPUT_DIRECTORY_NAME } = require('../../constants');
|
|
14
|
-
const { cmd, hvy, opt } = require('../../utils/color');
|
|
15
|
-
const { success } = require('../../utils/logging');
|
|
16
|
-
const { installDependencies } = require('../../utils/npm');
|
|
17
|
-
const { combine } = require('../../utils/structures');
|
|
18
|
-
const { sluggify } = require('../../utils/text');
|
|
19
|
-
const { projectExists } = require('../../utils/ftp');
|
|
20
|
-
const { log, warn, info } = importLazy('../../utils/logging');
|
|
21
|
-
|
|
22
|
-
module.exports = class extends Generator {
|
|
23
|
-
constructor(args, opts) {
|
|
24
|
-
super(args, {
|
|
25
|
-
...opts,
|
|
26
|
-
localConfigOnly: true
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
this.argument('name', {
|
|
30
|
-
description: `Project name. Create this directory if ${opt('--here')} is not specified`,
|
|
31
|
-
required: false
|
|
32
|
-
});
|
|
33
|
-
this.option('here', { description: `Assume ${opt('<name>')} is current working directory`, type: Boolean });
|
|
34
|
-
this.option('template', { description: 'Type of project [basic|preact|react|svelte]', type: String });
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
usage() {
|
|
38
|
-
return `${cmd('aunty generate project')} -- ${opt('[options] [<name>]')}
|
|
39
|
-
|
|
40
|
-
Two shorthands are available - ${cmd('aunty new')} and ${cmd('aunty init')} - for quick project creation.
|
|
41
|
-
|
|
42
|
-
Shorthand examples (assuming xyz is your project name):
|
|
43
|
-
|
|
44
|
-
${cmd('aunty new')} ==> ${cmd('aunty generate project')}
|
|
45
|
-
${cmd('aunty new')} ${opt('xyz')} ==> ${cmd('aunty generate project')} -- ${opt('xyz')}
|
|
46
|
-
${cmd('aunty init')} ==> ${cmd('aunty generate project')} -- ${opt('--here')}
|
|
47
|
-
`;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
async prompting() {
|
|
51
|
-
let prompts = [];
|
|
52
|
-
|
|
53
|
-
if (this.options.here) {
|
|
54
|
-
const currentDirectory = path.basename(process.cwd());
|
|
55
|
-
|
|
56
|
-
info(`Info: Using currect directory name as project name:`, currentDirectory);
|
|
57
|
-
log('Checking project name. This may take a few seconds...');
|
|
58
|
-
|
|
59
|
-
const [err, exists] = await wrap(projectExists(sluggify(currentDirectory)));
|
|
60
|
-
|
|
61
|
-
if (exists)
|
|
62
|
-
warn(
|
|
63
|
-
'Warning: Project with the same name detected externally. ' +
|
|
64
|
-
'Danger of data loss if you continue. ' +
|
|
65
|
-
'Press ctrl+c to exit and rename project directory.'
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
if (err)
|
|
69
|
-
warn(
|
|
70
|
-
'Warning: Unable to check if project name already exists, most likely ' +
|
|
71
|
-
'due to a connection or credentials error. Please check manually before deploying.\n'
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
this.options.projectName = currentDirectory;
|
|
75
|
-
} else {
|
|
76
|
-
prompts.push({
|
|
77
|
-
type: 'input',
|
|
78
|
-
name: 'projectName',
|
|
79
|
-
message: 'What is your project called?',
|
|
80
|
-
default: this.options.projectName || 'New Project',
|
|
81
|
-
validate: async input => {
|
|
82
|
-
log('\nChecking project name. This may take a few seconds...');
|
|
83
|
-
|
|
84
|
-
const [err, exists] = await wrap(projectExists(sluggify(input)));
|
|
85
|
-
|
|
86
|
-
if (exists)
|
|
87
|
-
return (
|
|
88
|
-
'Error: Project seems to aleady exist on the FTP server and is in ' +
|
|
89
|
-
'danger of being overwritten. Please try a different name.'
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
if (err)
|
|
93
|
-
warn(
|
|
94
|
-
'Warning: Unable to check if project name already exists, most likely ' +
|
|
95
|
-
'due to a connection or credentials error. Please check manually before deploying.\n'
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (!this.options.template) {
|
|
104
|
-
prompts.push({
|
|
105
|
-
type: 'list',
|
|
106
|
-
name: 'template',
|
|
107
|
-
message: 'What type of project is it?',
|
|
108
|
-
choices: [
|
|
109
|
-
{ name: 'Basic', value: 'basic' },
|
|
110
|
-
{ name: 'Preact', value: 'preact' },
|
|
111
|
-
{ name: 'React', value: 'react' },
|
|
112
|
-
{ name: 'Svelte', value: 'svelte' }
|
|
113
|
-
]
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
prompts.push({
|
|
118
|
-
type: 'confirm',
|
|
119
|
-
name: 'typescript',
|
|
120
|
-
message: 'Will you be authoring your project in TypeScript?',
|
|
121
|
-
default: true
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
prompts.push({
|
|
125
|
-
type: 'confirm',
|
|
126
|
-
name: 'odyssey',
|
|
127
|
-
message: 'Will this project render components inside an Odyssey?',
|
|
128
|
-
default: false
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
const answers = await this.prompt(prompts);
|
|
132
|
-
|
|
133
|
-
this.options = combine(this.options, answers);
|
|
134
|
-
|
|
135
|
-
this.options.projectName = this.options.projectName.replace(/[^\w\-\_\s]/g, '');
|
|
136
|
-
|
|
137
|
-
this.options.projectNameSlug = sluggify(this.options.projectName);
|
|
138
|
-
|
|
139
|
-
this.options.projectNameFlat = this.options.projectNameSlug.replace(/-/g, '');
|
|
140
|
-
|
|
141
|
-
if (this.options.here) {
|
|
142
|
-
this.options.path = process.cwd();
|
|
143
|
-
} else {
|
|
144
|
-
this.options.path = process.cwd() + '/' + this.options.projectNameSlug;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
async configuring() {
|
|
149
|
-
const directory = this.options.path;
|
|
150
|
-
|
|
151
|
-
await makeDir(directory);
|
|
152
|
-
process.chdir(directory);
|
|
153
|
-
this.destinationRoot(directory);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
writing() {
|
|
157
|
-
const context = {
|
|
158
|
-
OUTPUT_DIRECTORY_NAME,
|
|
159
|
-
projectName: this.options.projectName,
|
|
160
|
-
projectNameSlug: this.options.projectNameSlug,
|
|
161
|
-
projectNameFlat: this.options.projectNameFlat,
|
|
162
|
-
projectType: this.options.template,
|
|
163
|
-
isTS: this.options.typescript,
|
|
164
|
-
isOdyssey: this.options.odyssey,
|
|
165
|
-
authorName: this.user.git.name(),
|
|
166
|
-
authorEmail: this.user.git.email()
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
const hasSFCs = this.options.template === 'svelte';
|
|
170
|
-
const templateDirs = [this.options.template, '_common'].concat(hasSFCs ? [] : ['_non_sfc']);
|
|
171
|
-
const templateDirPaths = templateDirs.map(dir => this.templatePath(dir));
|
|
172
|
-
const pathExclusions = [].concat(this.options.typescript ? [] : ['tsconfig.json']);
|
|
173
|
-
const pathReplacements = templateDirPaths
|
|
174
|
-
.map(dirPath => [`${dirPath}/`, ''])
|
|
175
|
-
.concat(this.options.typescript ? [] : [[/\.tsx?/, '.js']], [['_.', '.']]);
|
|
176
|
-
|
|
177
|
-
getAllPaths(...templateDirPaths).forEach(filePath => {
|
|
178
|
-
if (pathExclusions.some(exclusion => filePath.includes(exclusion))) {
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
this.fs.copyTpl(
|
|
183
|
-
filePath,
|
|
184
|
-
this.destinationPath(
|
|
185
|
-
pathReplacements.reduce((filePath, replacement) => filePath.replace(...replacement), filePath)
|
|
186
|
-
),
|
|
187
|
-
context
|
|
188
|
-
);
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
async install() {
|
|
193
|
-
let auntyVersion;
|
|
194
|
-
|
|
195
|
-
try {
|
|
196
|
-
auntyVersion = requireg('@abcnews/aunty/package.json').version;
|
|
197
|
-
} catch (ex) {
|
|
198
|
-
// Nothing
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
const devDependencies = [`@abcnews/aunty${auntyVersion ? `@${auntyVersion}` : ''}`].concat(
|
|
202
|
-
this.options.typescript ? ['@types/jest', '@types/webpack-env'] : []
|
|
203
|
-
);
|
|
204
|
-
const dependencies = ['@abcnews/alternating-case-to-object', '@abcnews/env-utils', '@abcnews/mount-utils'];
|
|
205
|
-
|
|
206
|
-
switch (this.options.template) {
|
|
207
|
-
case 'preact':
|
|
208
|
-
devDependencies.push('html-looks-like', 'preact-render-to-string');
|
|
209
|
-
dependencies.push('preact');
|
|
210
|
-
break;
|
|
211
|
-
case 'react':
|
|
212
|
-
devDependencies.push(
|
|
213
|
-
'react-test-renderer',
|
|
214
|
-
...(this.options.typescript ? ['@types/react', '@types/react-dom', '@types/react-test-renderer'] : [])
|
|
215
|
-
);
|
|
216
|
-
dependencies.push('react', 'react-dom');
|
|
217
|
-
break;
|
|
218
|
-
case 'svelte':
|
|
219
|
-
devDependencies.push('@testing-library/svelte');
|
|
220
|
-
dependencies.push('svelte@5');
|
|
221
|
-
break;
|
|
222
|
-
default:
|
|
223
|
-
break;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
const allDependencies = [].concat(devDependencies).concat(dependencies);
|
|
227
|
-
const projectDirectoryName = this.options.path.split('/').reverse()[0];
|
|
228
|
-
|
|
229
|
-
if (allDependencies.includes(projectDirectoryName)) {
|
|
230
|
-
throw new Error(
|
|
231
|
-
`npm will refuse to install a package ("${projectDirectoryName}") which matches the project directory name.`
|
|
232
|
-
);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
await installDependencies(devDependencies.sort(), ['--save-dev'], this.log);
|
|
236
|
-
await installDependencies(dependencies.sort(), null, this.log);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
end() {
|
|
240
|
-
const where = this.options.here ? 'the current directory' : `./${this.options.projectNameSlug}`;
|
|
241
|
-
|
|
242
|
-
success(`Created ${hvy(this.options.projectName)} project in ${hvy(where)}`);
|
|
243
|
-
}
|
|
244
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) <%= new Date().getFullYear() %> ABC News
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "<%= projectNameSlug %>",
|
|
3
|
-
"version": "1.0.0-pre",
|
|
4
|
-
"description": "A project generated from aunty's <%= projectType %> project template.",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"private": true,
|
|
7
|
-
"contributors": [
|
|
8
|
-
"<%= authorName %> <<%= authorEmail %>>"
|
|
9
|
-
],
|
|
10
|
-
"aunty": {
|
|
11
|
-
"type": "<%= projectType %>"
|
|
12
|
-
},
|
|
13
|
-
"scripts": {
|
|
14
|
-
"start": "aunty serve",
|
|
15
|
-
"dev": "aunty serve",
|
|
16
|
-
"test": "aunty test"
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
-
<title><%= projectName %></title>
|
|
7
|
-
<!-- If you add `extractCSS:true` to your build config, add the <link> below -->
|
|
8
|
-
<!-- <link rel="stylesheet" href="index.css" /> -->
|
|
9
|
-
<script src="index.js"></script>
|
|
10
|
-
<!-- If you add `addModernJS:true` to your build config, replace the <script> above with the ones below -->
|
|
11
|
-
<!-- <script type="module" src="index_modern.js"></script> -->
|
|
12
|
-
<!-- <script nomodule src="index.js"></script> -->
|
|
13
|
-
</head>
|
|
14
|
-
<body>
|
|
15
|
-
<div data-mount id="<%= projectNameFlat %>X42YtextZtrue"></div><% if (isOdyssey) { %>
|
|
16
|
-
<!-- Mock Odyssey's loaded event so the `whenOdysseyLoaded` promise resolves -->
|
|
17
|
-
<script>
|
|
18
|
-
window.dispatchEvent(new CustomEvent('odyssey:api'));
|
|
19
|
-
</script><% } %>
|
|
20
|
-
</body>
|
|
21
|
-
</html>
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
<svg version="1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 300">
|
|
2
|
-
<path fill="#<% if (isTS) { %>fff<% } else { %>000<% } %>" d="M57.733.28c15.15-.238 33.573 5.428 46 20.76 5.63 5.447 15.973 31.627 15.973 31.627l61.955 164.537c7.97 19.756 31.93 21.236 38.965 1.488L239.87 166.8l32.858 86.48c-15.973 29.157-31.435 36.304-49.765 42.966-21.346 6.68-46.932 4.477-65.245-6.9-6.086-3.947-22.06-14.318-32.86-40.516L59.616 66.494V232.53l24.417-70.16 31.325 87.586c-4.57 20.113-19.116 36.918-36.02 44.822-18.496 8.717-40.555 5.63-57.277-4.945C5.41 277.48.715 262.903 0 236.96L.22 57.366c1.9-29.91 21.017-46.193 37.794-53.486C45.67 1.16 48.944.418 57.734.28z"/>
|
|
3
|
-
<path fill="#<% if (isTS) { %>fff<% } else { %>000<% } %>" d="M343.146 299.71c-15.15.267-33.572-5.427-46.02-20.733-5.628-5.445-15.954-31.625-15.954-31.625L219.22 82.814c-7.987-19.784-31.93-21.264-38.965-1.5L161.01 133.21l-32.86-86.48c15.955-29.132 31.453-36.306 49.765-42.985 21.364-6.68 46.95-4.45 65.245 6.926 6.104 3.95 22.06 14.32 32.86 40.52l65.243 182.31V67.49l-24.397 70.16-31.344-87.586c4.57-20.14 19.135-36.926 36.04-44.82 18.478-8.7 40.555-5.64 57.258 4.942 16.668 12.327 21.347 26.93 22.06 52.845l-.237 179.626c-1.864 29.908-21 46.2-37.795 53.484-7.603 2.712-10.893 3.442-19.702 3.57z"/>
|
|
4
|
-
</svg>
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
.root {
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-direction: column;
|
|
4
|
-
justify-content: center;
|
|
5
|
-
align-items: center;
|
|
6
|
-
width: 100%;
|
|
7
|
-
height: 100%;
|
|
8
|
-
min-height: 320px;
|
|
9
|
-
background-color: #<% if (isTS) { %>3178c7<% } else { %>f0db4e<% } %>;
|
|
10
|
-
color: #<% if (isTS) { %>fff<% } else { %>000<% } %>;
|
|
11
|
-
text-align: center;
|
|
12
|
-
|
|
13
|
-
h1 {
|
|
14
|
-
margin: 0;
|
|
15
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif !important;
|
|
16
|
-
font-size: 24px !important;
|
|
17
|
-
font-weight: normal !important;
|
|
18
|
-
line-height: normal !important;
|
|
19
|
-
letter-spacing: normal !important;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
.root {
|
|
2
|
-
position: fixed;
|
|
3
|
-
overflow: auto;
|
|
4
|
-
left: 0;
|
|
5
|
-
top: 0;
|
|
6
|
-
z-index: 10000;
|
|
7
|
-
box-sizing: border-box;
|
|
8
|
-
margin: 0;
|
|
9
|
-
padding: 2rem;
|
|
10
|
-
width: 100vw;
|
|
11
|
-
height: 100vh;
|
|
12
|
-
background-color: #900;
|
|
13
|
-
color: #fff;
|
|
14
|
-
font-family: Menlo, Consolas, monospace;
|
|
15
|
-
font-size: large;
|
|
16
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import App from './index';<% if (isTS) { %>
|
|
2
|
-
import type { AppProps } from './index';<% } %>
|
|
3
|
-
|
|
4
|
-
test('it renders', () => {
|
|
5
|
-
const props<% if (isTS) { %>: AppProps<% } %> = { x: 42, y: 'text', z: true };
|
|
6
|
-
const component = new App(props);
|
|
7
|
-
|
|
8
|
-
expect(component.el.innerHTML).toContain(JSON.stringify(props));
|
|
9
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import Worm from '../Worm';
|
|
2
|
-
import styles from './styles.scss';
|
|
3
|
-
<% if (isTS) { %>
|
|
4
|
-
export type AppProps = {
|
|
5
|
-
x: number;
|
|
6
|
-
y: string;
|
|
7
|
-
z: boolean;
|
|
8
|
-
}
|
|
9
|
-
<% } %>
|
|
10
|
-
export default class App {<% if (isTS) { %>
|
|
11
|
-
el: Element;
|
|
12
|
-
<% } %>
|
|
13
|
-
constructor({ x, y, z }<% if (isTS) { %>: AppProps<% } %>) {
|
|
14
|
-
this.el = document.createElement('div');
|
|
15
|
-
this.el.className = styles.root;
|
|
16
|
-
this.el.innerHTML = `
|
|
17
|
-
${new Worm().el.outerHTML}
|
|
18
|
-
<pre>${JSON.stringify({ x, y, z })}</pre>
|
|
19
|
-
<h1><%= projectName %></h1>
|
|
20
|
-
`;
|
|
21
|
-
}
|
|
22
|
-
}
|