@abcnews/aunty 16.0.0 → 17.0.0-next.0
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 +10 -0
- package/dist/bin/aunty.js +3 -0
- package/dist/lib/constants.js +8 -0
- package/package.json +25 -82
- 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,30 +0,0 @@
|
|
|
1
|
-
import { select<% if (isTS) { %>, Selection<% } %> } from 'd3-selection';
|
|
2
|
-
import styles from './styles.scss';
|
|
3
|
-
|
|
4
|
-
export default class <%= className %> {<% if (isTS) { %>
|
|
5
|
-
el: Element;
|
|
6
|
-
svg: Selection<SVGSVGElement, unknown, null, undefined>;
|
|
7
|
-
g: Selection<SVGGElement, unknown, null, undefined>;
|
|
8
|
-
rect: Selection<SVGRectElement, any, any, any>;
|
|
9
|
-
<% } %>
|
|
10
|
-
constructor() {
|
|
11
|
-
this.el = document.createElement('div');
|
|
12
|
-
this.el.className = styles.root;
|
|
13
|
-
|
|
14
|
-
this.svg = select(this.el)
|
|
15
|
-
.append('svg')
|
|
16
|
-
.attr('width', 400)
|
|
17
|
-
.attr('height', 300);
|
|
18
|
-
|
|
19
|
-
this.g = this.svg.append('g').attr('fill', 'black');
|
|
20
|
-
|
|
21
|
-
this.rect = this.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
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import styles from './styles.scss';
|
|
2
|
-
|
|
3
|
-
export default class <%= className %> {<% if (isTS) { %>
|
|
4
|
-
el: Element;
|
|
5
|
-
<% } %>
|
|
6
|
-
constructor() {
|
|
7
|
-
this.el = document.createElement('div');
|
|
8
|
-
this.el.className = styles.root;
|
|
9
|
-
this.el.innerHTML = `Find me in <strong>src/components/<%= className %></strong>`;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,16 +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></div>
|
|
12
|
-
`;
|
|
13
|
-
|
|
14
|
-
htmlLooksLike(actual, expected);
|
|
15
|
-
});
|
|
16
|
-
});
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { select<% if (isTS) { %>, Selection<% } %> } from 'd3-selection';
|
|
2
|
-
import { h<% if (isTS) { %>, FunctionalComponent<% } %> } from 'preact';
|
|
3
|
-
import { useEffect, useRef } from 'preact/hooks';
|
|
4
|
-
import styles from './styles.scss';
|
|
5
|
-
<% if (isTS) { %>
|
|
6
|
-
type <%= className %>Props = {
|
|
7
|
-
color?: string;
|
|
8
|
-
}
|
|
9
|
-
<% } %>
|
|
10
|
-
const <%= className %><% if (isTS) { %>: FunctionalComponent<<%= className %>Props><% } %> = ({ color = 'black' }) => {
|
|
11
|
-
const root = useRef<% if (isTS) { %><Element | null><% } %>(null);
|
|
12
|
-
const svg = useRef<% if (isTS) { %><Selection<SVGSVGElement, unknown, null, undefined> | null><% } %>(null);
|
|
13
|
-
const g = useRef<% if (isTS) { %><Selection<SVGGElement, unknown, null, undefined> | null><% } %>(null);
|
|
14
|
-
const rect = useRef<% if (isTS) { %><Selection<SVGRectElement, unknown, null, undefined> | null><% } %>(null);
|
|
15
|
-
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
svg.current = select(root.current)
|
|
18
|
-
.append('svg')
|
|
19
|
-
.attr('width', 400)
|
|
20
|
-
.attr('height', 300);
|
|
21
|
-
|
|
22
|
-
g.current = svg.current.append('g');
|
|
23
|
-
|
|
24
|
-
rect.current = g.current
|
|
25
|
-
.append('rect')
|
|
26
|
-
.attr('x', 0)
|
|
27
|
-
.attr('y', 0)
|
|
28
|
-
.attr('rx', 3)
|
|
29
|
-
.attr('ry', 3)
|
|
30
|
-
.attr('width', '100%')
|
|
31
|
-
.attr('height', '100%');
|
|
32
|
-
}, []);
|
|
33
|
-
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
if (!g.current) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
g.current.attr('fill', color);
|
|
40
|
-
}, [color]);
|
|
41
|
-
|
|
42
|
-
return <div ref={root} className={styles.root}></div>;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export default <%= className %>;
|
|
@@ -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
|
-
}
|