@apollion-dsi/scripts 0.7.7
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/.prettierignore +6 -0
- package/.prettierrc.js +1 -0
- package/CHANGELOG.md +8 -0
- package/README.MD +91 -0
- package/audit-ci.json +5 -0
- package/eslint.config.js +33 -0
- package/lib/bin.d.ts +2 -0
- package/lib/bin.js +34 -0
- package/lib/bin.js.map +1 -0
- package/lib/command/build.d.ts +3 -0
- package/lib/command/build.js +145 -0
- package/lib/command/build.js.map +1 -0
- package/lib/command/create/helper.d.ts +7 -0
- package/lib/command/create/helper.js +98 -0
- package/lib/command/create/helper.js.map +1 -0
- package/lib/command/create/index.d.ts +1 -0
- package/lib/command/create/index.js +149 -0
- package/lib/command/create/index.js.map +1 -0
- package/lib/command/dev.d.ts +3 -0
- package/lib/command/dev.js +85 -0
- package/lib/command/dev.js.map +1 -0
- package/lib/command/test.d.ts +1 -0
- package/lib/command/test.js +32 -0
- package/lib/command/test.js.map +1 -0
- package/lib/config/env.d.ts +15 -0
- package/lib/config/env.js +78 -0
- package/lib/config/env.js.map +1 -0
- package/lib/config/modules.d.ts +15 -0
- package/lib/config/modules.js +92 -0
- package/lib/config/modules.js.map +1 -0
- package/lib/config/paths.d.ts +22 -0
- package/lib/config/paths.js +61 -0
- package/lib/config/paths.js.map +1 -0
- package/lib/config/shared.d.ts +24 -0
- package/lib/config/shared.js +14 -0
- package/lib/config/shared.js.map +1 -0
- package/lib/config/webpack.config.d.ts +187 -0
- package/lib/config/webpack.config.js +300 -0
- package/lib/config/webpack.config.js.map +1 -0
- package/lib/config/webpackDevServer.config.d.ts +34 -0
- package/lib/config/webpackDevServer.config.js +67 -0
- package/lib/config/webpackDevServer.config.js.map +1 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +10 -0
- package/lib/index.js.map +1 -0
- package/lib/utils/FileSizeReporter.d.ts +12 -0
- package/lib/utils/FileSizeReporter.js +151 -0
- package/lib/utils/FileSizeReporter.js.map +1 -0
- package/lib/utils/InlineChunkHtmlPlugin.d.ts +8 -0
- package/lib/utils/InlineChunkHtmlPlugin.js +54 -0
- package/lib/utils/InlineChunkHtmlPlugin.js.map +1 -0
- package/lib/utils/InterpolateHtmlPlugin.d.ts +7 -0
- package/lib/utils/InterpolateHtmlPlugin.js +21 -0
- package/lib/utils/InterpolateHtmlPlugin.js.map +1 -0
- package/lib/utils/ModuleNotFoundPlugin.d.ts +5 -0
- package/lib/utils/ModuleNotFoundPlugin.js +11 -0
- package/lib/utils/ModuleNotFoundPlugin.js.map +1 -0
- package/lib/utils/ModuleScopePlugin.d.ts +5 -0
- package/lib/utils/ModuleScopePlugin.js +11 -0
- package/lib/utils/ModuleScopePlugin.js.map +1 -0
- package/lib/utils/WebpackDevServerUtils.d.ts +22 -0
- package/lib/utils/WebpackDevServerUtils.js +154 -0
- package/lib/utils/WebpackDevServerUtils.js.map +1 -0
- package/lib/utils/checkRequiredFiles.d.ts +1 -0
- package/lib/utils/checkRequiredFiles.js +28 -0
- package/lib/utils/checkRequiredFiles.js.map +1 -0
- package/lib/utils/devServerMiddleware.d.ts +8 -0
- package/lib/utils/devServerMiddleware.js +19 -0
- package/lib/utils/devServerMiddleware.js.map +1 -0
- package/lib/utils/formatWebpackMessages.d.ts +5 -0
- package/lib/utils/formatWebpackMessages.js +32 -0
- package/lib/utils/formatWebpackMessages.js.map +1 -0
- package/lib/utils/getPublicUrlOrPath.d.ts +1 -0
- package/lib/utils/getPublicUrlOrPath.js +39 -0
- package/lib/utils/getPublicUrlOrPath.js.map +1 -0
- package/lib/utils/printBuildError.d.ts +1 -0
- package/lib/utils/printBuildError.js +14 -0
- package/lib/utils/printBuildError.js.map +1 -0
- package/lib/utils/printHostingInstructions.d.ts +1 -0
- package/lib/utils/printHostingInstructions.js +12 -0
- package/lib/utils/printHostingInstructions.js.map +1 -0
- package/package.json +81 -0
- package/scripts/validate.sh +16 -0
- package/src/bin.ts +41 -0
- package/src/command/build.ts +188 -0
- package/src/command/create/helper.ts +97 -0
- package/src/command/create/index.ts +200 -0
- package/src/command/dev.ts +95 -0
- package/src/command/test.ts +33 -0
- package/src/config/env.ts +82 -0
- package/src/config/modules.ts +115 -0
- package/src/config/paths.ts +88 -0
- package/src/config/shared.ts +27 -0
- package/src/config/webpack.config.js +308 -0
- package/src/config/webpackDevServer.config.ts +78 -0
- package/src/index.ts +3 -0
- package/src/utils/FileSizeReporter.ts +168 -0
- package/src/utils/InlineChunkHtmlPlugin.js +67 -0
- package/src/utils/InterpolateHtmlPlugin.js +27 -0
- package/src/utils/ModuleNotFoundPlugin.js +13 -0
- package/src/utils/ModuleScopePlugin.js +13 -0
- package/src/utils/WebpackDevServerUtils.ts +179 -0
- package/src/utils/checkRequiredFiles.ts +22 -0
- package/src/utils/devServerMiddleware.ts +20 -0
- package/src/utils/formatWebpackMessages.ts +30 -0
- package/src/utils/getPublicUrlOrPath.ts +39 -0
- package/src/utils/printBuildError.ts +8 -0
- package/src/utils/printHostingInstructions.ts +12 -0
- package/template/.editorconfig +43 -0
- package/template/.prettierignore +6 -0
- package/template/.prettierrc.js +1 -0
- package/template/audit-ci.json +5 -0
- package/template/commitlint.config.js +1 -0
- package/template/eslint.config.js +3 -0
- package/template/jest.config.js +4 -0
- package/template/public/index.html +20 -0
- package/template/src/App.test.tsx +10 -0
- package/template/src/App.tsx +35 -0
- package/template/src/index.tsx +10 -0
- package/template/tsconfig.json +25 -0
- package/tsconfig.json +18 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import os from 'os';
|
|
2
|
+
import url from 'url';
|
|
3
|
+
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
|
|
6
|
+
import formatWebpackMessages from './formatWebpackMessages';
|
|
7
|
+
|
|
8
|
+
// detect-port@2 is ESM-only; load lazily via native dynamic import so we stay CJS-compatible.
|
|
9
|
+
// Wrapped in Function() so TypeScript's CommonJS emitter doesn't downlevel it to require().
|
|
10
|
+
const dynamicImport = new Function('specifier', 'return import(specifier)') as (specifier: string) => Promise<any>;
|
|
11
|
+
|
|
12
|
+
async function detectPort(port: number): Promise<number> {
|
|
13
|
+
const mod: any = await dynamicImport('detect-port');
|
|
14
|
+
const fn = mod.default ?? mod.detect ?? mod;
|
|
15
|
+
return fn(port);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type PreparedUrls = {
|
|
19
|
+
lanUrlForConfig?: string;
|
|
20
|
+
lanUrlForTerminal?: string;
|
|
21
|
+
localUrlForTerminal: string;
|
|
22
|
+
localUrlForBrowser: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
function getLanIp(): string | undefined {
|
|
26
|
+
const ifaces = os.networkInterfaces();
|
|
27
|
+
for (const name of Object.keys(ifaces)) {
|
|
28
|
+
const list = ifaces[name];
|
|
29
|
+
if (!list) continue;
|
|
30
|
+
for (const iface of list) {
|
|
31
|
+
if (iface.family === 'IPv4' && !iface.internal) {
|
|
32
|
+
return iface.address;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function formatUrl(protocol: string, hostname: string, port: number, pathname: string): string {
|
|
40
|
+
return url.format({
|
|
41
|
+
protocol,
|
|
42
|
+
hostname,
|
|
43
|
+
port,
|
|
44
|
+
pathname: pathname || '/',
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function prepareUrls(protocol: string, host: string, port: number, pathname: string = '/'): PreparedUrls {
|
|
49
|
+
const isUnspecifiedHost = host === '0.0.0.0' || host === '::';
|
|
50
|
+
let prettyHost = host;
|
|
51
|
+
let lanUrlForConfig: string | undefined;
|
|
52
|
+
let lanUrlForTerminal: string | undefined;
|
|
53
|
+
|
|
54
|
+
if (isUnspecifiedHost) {
|
|
55
|
+
prettyHost = 'localhost';
|
|
56
|
+
const lanIp = getLanIp();
|
|
57
|
+
if (lanIp) {
|
|
58
|
+
lanUrlForConfig = lanIp;
|
|
59
|
+
lanUrlForTerminal = formatUrl(protocol, lanIp, port, pathname);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const localUrlForTerminal = formatUrl(protocol, prettyHost, port, pathname);
|
|
64
|
+
const localUrlForBrowser = formatUrl(protocol, prettyHost, port, pathname);
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
lanUrlForConfig,
|
|
68
|
+
lanUrlForTerminal,
|
|
69
|
+
localUrlForTerminal,
|
|
70
|
+
localUrlForBrowser,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export async function choosePort(_host: string, defaultPort: number): Promise<number | null> {
|
|
75
|
+
try {
|
|
76
|
+
const port = await detectPort(defaultPort);
|
|
77
|
+
if (port === defaultPort) return port;
|
|
78
|
+
console.log(chalk.yellow(`Port ${defaultPort} is in use; using ${port} instead.`));
|
|
79
|
+
return port;
|
|
80
|
+
} catch (err) {
|
|
81
|
+
console.error(chalk.red(`Could not find a free port.`), err);
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
type PrepareProxyResult = any[] | undefined;
|
|
87
|
+
|
|
88
|
+
export function prepareProxy(proxy: unknown, _appPublicFolder?: string, _servedPathname?: string): PrepareProxyResult {
|
|
89
|
+
if (!proxy) return undefined;
|
|
90
|
+
|
|
91
|
+
if (typeof proxy === 'string') {
|
|
92
|
+
return [
|
|
93
|
+
{
|
|
94
|
+
context: (pathname: string) => {
|
|
95
|
+
return pathname !== '/' && !pathname.startsWith('/sockjs-node') && !pathname.startsWith('/ws');
|
|
96
|
+
},
|
|
97
|
+
target: proxy,
|
|
98
|
+
changeOrigin: true,
|
|
99
|
+
secure: false,
|
|
100
|
+
},
|
|
101
|
+
];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (Array.isArray(proxy)) return proxy;
|
|
105
|
+
|
|
106
|
+
// proxy as object (legacy CRA shape: { "/api": { target: ... } })
|
|
107
|
+
if (typeof proxy === 'object') {
|
|
108
|
+
return Object.entries(proxy as Record<string, any>).map(([context, value]) => {
|
|
109
|
+
if (value && typeof value === 'object') {
|
|
110
|
+
return { context: [context], ...value };
|
|
111
|
+
}
|
|
112
|
+
return { context: [context], target: value };
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return undefined;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export type CreateCompilerOptions = {
|
|
120
|
+
appName: string;
|
|
121
|
+
config: any;
|
|
122
|
+
urls: PreparedUrls;
|
|
123
|
+
useYarn?: boolean;
|
|
124
|
+
useTypeScript?: boolean;
|
|
125
|
+
tscCompileOnError?: boolean;
|
|
126
|
+
webpack: any;
|
|
127
|
+
devSocket?: unknown;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export function createCompiler({ appName, config, urls, webpack }: CreateCompilerOptions): any {
|
|
131
|
+
let compiler;
|
|
132
|
+
try {
|
|
133
|
+
compiler = webpack(config);
|
|
134
|
+
} catch (err) {
|
|
135
|
+
console.log(chalk.red('Failed to compile.'));
|
|
136
|
+
console.log();
|
|
137
|
+
console.log((err as Error).message || err);
|
|
138
|
+
console.log();
|
|
139
|
+
process.exit(1);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
compiler.hooks.invalid.tap('invalid', () => {
|
|
143
|
+
console.log();
|
|
144
|
+
console.log('Compiling...');
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
compiler.hooks.done.tap('done', (stats: any) => {
|
|
148
|
+
const statsData = stats.toJson({ all: false, warnings: true, errors: true });
|
|
149
|
+
const messages = formatWebpackMessages(statsData);
|
|
150
|
+
const isSuccessful = !messages.errors.length && !messages.warnings.length;
|
|
151
|
+
|
|
152
|
+
if (isSuccessful) {
|
|
153
|
+
console.log(chalk.green(`Compiled successfully!`));
|
|
154
|
+
console.log();
|
|
155
|
+
console.log(`You can now view ${chalk.bold(appName)} in the browser.`);
|
|
156
|
+
if (urls.lanUrlForTerminal) {
|
|
157
|
+
console.log(` ${chalk.bold('Local:')} ${urls.localUrlForTerminal}`);
|
|
158
|
+
console.log(` ${chalk.bold('On Your Network:')} ${urls.lanUrlForTerminal}`);
|
|
159
|
+
} else {
|
|
160
|
+
console.log(` ${urls.localUrlForTerminal}`);
|
|
161
|
+
}
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (messages.errors.length) {
|
|
166
|
+
if (messages.errors.length > 1) messages.errors.length = 1;
|
|
167
|
+
console.log(chalk.red('Failed to compile.\n'));
|
|
168
|
+
console.log(messages.errors.join('\n\n'));
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (messages.warnings.length) {
|
|
173
|
+
console.log(chalk.yellow('Compiled with warnings.\n'));
|
|
174
|
+
console.log(messages.warnings.join('\n\n'));
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
return compiler;
|
|
179
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
|
|
6
|
+
export default function checkRequiredFiles(files: string[]): boolean {
|
|
7
|
+
let currentFilePath: string | undefined;
|
|
8
|
+
try {
|
|
9
|
+
files.forEach((filePath) => {
|
|
10
|
+
currentFilePath = filePath;
|
|
11
|
+
fs.accessSync(filePath, fs.constants.F_OK);
|
|
12
|
+
});
|
|
13
|
+
return true;
|
|
14
|
+
} catch (err) {
|
|
15
|
+
const dirName = currentFilePath ? path.dirname(currentFilePath) : '';
|
|
16
|
+
const fileName = currentFilePath ? path.basename(currentFilePath) : '';
|
|
17
|
+
console.log(chalk.red('Could not find a required file.'));
|
|
18
|
+
console.log(` ${chalk.red('Name')}: ${chalk.cyan(fileName)}`);
|
|
19
|
+
console.log(` ${chalk.red('Searched in')}: ${chalk.cyan(dirName)}`);
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from 'http';
|
|
2
|
+
|
|
3
|
+
type NextFn = (err?: unknown) => void;
|
|
4
|
+
type Middleware = (req: IncomingMessage, res: ServerResponse, next: NextFn) => void;
|
|
5
|
+
|
|
6
|
+
export function evalSourceMapMiddleware(_devServer?: unknown): Middleware {
|
|
7
|
+
return (_req, _res, next) => next();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function ignoredFiles(appSrc: string): RegExp {
|
|
11
|
+
return new RegExp(`^(?!${appSrc}).+/node_modules/`, 'i');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function noopServiceWorkerMiddleware(_servedPath?: string): Middleware {
|
|
15
|
+
return (_req, _res, next) => next();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function redirectServedPathMiddleware(_servedPath?: string): Middleware {
|
|
19
|
+
return (_req, _res, next) => next();
|
|
20
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type FormattedMessages = {
|
|
2
|
+
errors: string[];
|
|
3
|
+
warnings: string[];
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
function toString(item: unknown): string {
|
|
7
|
+
if (item == null) return '';
|
|
8
|
+
if (typeof item === 'string') return item;
|
|
9
|
+
if (typeof item === 'object') {
|
|
10
|
+
const anyItem = item as any;
|
|
11
|
+
if (typeof anyItem.message === 'string') {
|
|
12
|
+
let result = '';
|
|
13
|
+
if (anyItem.moduleName) result += `in ${anyItem.moduleName}\n\n`;
|
|
14
|
+
result += anyItem.message;
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
return JSON.stringify(anyItem);
|
|
19
|
+
} catch {
|
|
20
|
+
return String(anyItem);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return String(item);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default function formatWebpackMessages(json: any): FormattedMessages {
|
|
27
|
+
const errors = Array.isArray(json?.errors) ? json.errors.map(toString) : [];
|
|
28
|
+
const warnings = Array.isArray(json?.warnings) ? json.warnings.map(toString) : [];
|
|
29
|
+
return { errors, warnings };
|
|
30
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { URL } from 'url';
|
|
2
|
+
|
|
3
|
+
export default function getPublicUrlOrPath(
|
|
4
|
+
isEnvDevelopment: boolean,
|
|
5
|
+
homepage: string | undefined,
|
|
6
|
+
envPublicUrl: string | undefined,
|
|
7
|
+
): string {
|
|
8
|
+
const stubDomain = 'https://create-react-app.dev';
|
|
9
|
+
|
|
10
|
+
if (envPublicUrl) {
|
|
11
|
+
let normalized = envPublicUrl;
|
|
12
|
+
if (!normalized.endsWith('/')) normalized += '/';
|
|
13
|
+
try {
|
|
14
|
+
const validPublicUrl = new URL(normalized, stubDomain);
|
|
15
|
+
return isEnvDevelopment ? (normalized.startsWith('.') ? '/' : validPublicUrl.pathname) : normalized;
|
|
16
|
+
} catch {
|
|
17
|
+
return normalized;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (homepage) {
|
|
22
|
+
let normalized = homepage;
|
|
23
|
+
if (!normalized.endsWith('/')) normalized += '/';
|
|
24
|
+
try {
|
|
25
|
+
const validHomepagePathname = new URL(normalized, stubDomain).pathname;
|
|
26
|
+
return isEnvDevelopment
|
|
27
|
+
? normalized.startsWith('.')
|
|
28
|
+
? '/'
|
|
29
|
+
: validHomepagePathname
|
|
30
|
+
: normalized.startsWith('.')
|
|
31
|
+
? normalized
|
|
32
|
+
: validHomepagePathname;
|
|
33
|
+
} catch {
|
|
34
|
+
return normalized;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return '/';
|
|
39
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
|
|
3
|
+
export default function printHostingInstructions(
|
|
4
|
+
_appPackage: unknown,
|
|
5
|
+
_publicUrl: string,
|
|
6
|
+
_publicPath: string | undefined,
|
|
7
|
+
buildFolder: string,
|
|
8
|
+
_useYarn: boolean,
|
|
9
|
+
): void {
|
|
10
|
+
console.log(`The build is ready in the ${chalk.cyan(buildFolder)} folder.`);
|
|
11
|
+
console.log('You may serve it with any static file server.');
|
|
12
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# top-most EditorConfig file
|
|
2
|
+
root = true
|
|
3
|
+
|
|
4
|
+
# Unix-style newlines with a newline ending every file
|
|
5
|
+
[**]
|
|
6
|
+
end_of_line = lf
|
|
7
|
+
insert_final_newline = true
|
|
8
|
+
|
|
9
|
+
# Standard at: https://github.com/felixge/node-style-guide
|
|
10
|
+
[**.{js,jsx,ts,tsx,json}]
|
|
11
|
+
trim_trailing_whitespace = true
|
|
12
|
+
indent_style = space
|
|
13
|
+
indent_size = 2
|
|
14
|
+
quote_type = single
|
|
15
|
+
curly_bracket_next_line = false
|
|
16
|
+
spaces_around_operators = true
|
|
17
|
+
space_after_control_statements = true
|
|
18
|
+
space_after_anonymous_functions = true
|
|
19
|
+
spaces_in_brackets = false
|
|
20
|
+
|
|
21
|
+
# No Standard. Please document a standard if different from .js
|
|
22
|
+
[**.{yml,css}]
|
|
23
|
+
trim_trailing_whitespace = true
|
|
24
|
+
indent_style = tab
|
|
25
|
+
|
|
26
|
+
[**.html]
|
|
27
|
+
trim_trailing_whitespace = true
|
|
28
|
+
indent_style = space
|
|
29
|
+
indent_size = 2
|
|
30
|
+
|
|
31
|
+
# No standard. Please document a standard if different from .js
|
|
32
|
+
[**.md]
|
|
33
|
+
indent_style = tab
|
|
34
|
+
|
|
35
|
+
# Standard at:
|
|
36
|
+
[Makefile]
|
|
37
|
+
indent_style = tab
|
|
38
|
+
|
|
39
|
+
# The indentation in package.json will always need to be 2 spaces
|
|
40
|
+
# https://github.com/npm/npm/issues/4718
|
|
41
|
+
[{package, bower}.json]
|
|
42
|
+
indent_style = space
|
|
43
|
+
indent_size = 2
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('@apollion-dsi/eslint-config/prettier.config');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = { extends: ['@commitlint/config-conventional'] };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="pt-br">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<base href="/" />
|
|
6
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
|
7
|
+
<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no,user-scalable=no" />
|
|
8
|
+
<meta name="description" content="Código gerado usando 'Apollion Scripts'" />
|
|
9
|
+
<link data-react-helmet="true" rel="shortcut icon" href="https://apollion.captalysplatform.io/img/favicon.ico" />
|
|
10
|
+
<link
|
|
11
|
+
href="https://fonts.googleapis.com/css2?family=Mulish:ital,wght@0,300;0,400;0,600;0,900;1,300;1,400;1,600;1,900&display=swap"
|
|
12
|
+
rel="stylesheet"
|
|
13
|
+
/>
|
|
14
|
+
<title>Apollion Framework</title>
|
|
15
|
+
</head>
|
|
16
|
+
<body>
|
|
17
|
+
<noscript>Ative o JavaScript em seu navegador para visualizar este Web Site</noscript>
|
|
18
|
+
<div id="root"></div>
|
|
19
|
+
</body>
|
|
20
|
+
</html>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
import { Root } from './App';
|
|
5
|
+
|
|
6
|
+
test('renders the button', () => {
|
|
7
|
+
const { getByTestId } = render(<Root />);
|
|
8
|
+
|
|
9
|
+
expect(getByTestId('notify_button')).toHaveTextContent('Aperte Aqui');
|
|
10
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ApollionProvider, Button, Flex, GlobalStyle, Text, useNotification } from '@apollion-dsi/core';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
function App() {
|
|
5
|
+
const { showNotification } = useNotification();
|
|
6
|
+
|
|
7
|
+
return (
|
|
8
|
+
<Flex gap="giant" p="giant">
|
|
9
|
+
<Text textAlign="center" variant="h2" color="warning.dark">
|
|
10
|
+
Ola, <Text color="main">Mundo</Text>
|
|
11
|
+
</Text>
|
|
12
|
+
|
|
13
|
+
<Button
|
|
14
|
+
data-testid="notify_button"
|
|
15
|
+
text="Aperte Aqui"
|
|
16
|
+
onClick={() => {
|
|
17
|
+
showNotification({
|
|
18
|
+
title: 'kkkkk',
|
|
19
|
+
message: 'ERRRROOOUUUUUUUUU',
|
|
20
|
+
autoClose: 10,
|
|
21
|
+
});
|
|
22
|
+
}}
|
|
23
|
+
/>
|
|
24
|
+
</Flex>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function Root() {
|
|
29
|
+
return (
|
|
30
|
+
<ApollionProvider>
|
|
31
|
+
<GlobalStyle />
|
|
32
|
+
<App />
|
|
33
|
+
</ApollionProvider>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es5",
|
|
4
|
+
"lib": [
|
|
5
|
+
"dom",
|
|
6
|
+
"dom.iterable",
|
|
7
|
+
"esnext"
|
|
8
|
+
],
|
|
9
|
+
"allowJs": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"allowSyntheticDefaultImports": true,
|
|
13
|
+
"strict": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true,
|
|
15
|
+
"module": "esnext",
|
|
16
|
+
"moduleResolution": "node",
|
|
17
|
+
"resolveJsonModule": true,
|
|
18
|
+
"isolatedModules": true,
|
|
19
|
+
"noEmit": true,
|
|
20
|
+
"jsx": "react"
|
|
21
|
+
},
|
|
22
|
+
"include": [
|
|
23
|
+
"src"
|
|
24
|
+
]
|
|
25
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"include": ["src"],
|
|
3
|
+
"exclude": ["./src/template"],
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"outDir": "lib",
|
|
6
|
+
"rootDir": "src",
|
|
7
|
+
"module": "node16",
|
|
8
|
+
"target": "es2020",
|
|
9
|
+
"moduleResolution": "node16",
|
|
10
|
+
"declaration": true,
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"strict": true,
|
|
13
|
+
"sourceMap": true,
|
|
14
|
+
"noImplicitAny": false,
|
|
15
|
+
"skipLibCheck": true,
|
|
16
|
+
"allowJs": true
|
|
17
|
+
}
|
|
18
|
+
}
|