gdu 5.0.4 → 5.2.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/dist/cli.js +5 -5
- package/dist/commands/build/buildSPA.js +4 -4
- package/dist/commands/build/buildSSR.js +3 -3
- package/dist/commands/build/index.js +8 -8
- package/dist/commands/configure/index.js +3 -3
- package/dist/commands/format.js +3 -3
- package/dist/commands/generateBrowsers.js +4 -4
- package/dist/commands/gh-actions.js +1 -1
- package/dist/commands/graphqlDiff.d.ts +2 -0
- package/dist/commands/graphqlDiff.js +68 -0
- package/dist/commands/graphqlDoc.d.ts +2 -0
- package/dist/commands/graphqlDoc.js +57 -0
- package/dist/commands/graphqlSchema.d.ts +11 -0
- package/dist/commands/graphqlSchema.js +11 -6
- package/dist/commands/index.js +24 -5
- package/dist/commands/scaffold.js +14 -14
- package/dist/commands/start/index.js +10 -6
- package/dist/commands/start/runSPA.js +13 -13
- package/dist/commands/start/runSSR.js +4 -4
- package/dist/config/next.config.d.ts +1 -2
- package/dist/config/next.config.js +29 -15
- package/dist/config/ssr/server.js +3 -3
- package/dist/config/webpack/plugins/GuruBuildManifest.js +2 -2
- package/dist/config/webpack/webpack.config.js +27 -23
- package/dist/lib/apps.js +2 -2
- package/dist/lib/banner.js +5 -5
- package/dist/lib/config.js +13 -11
- package/dist/lib/configure.js +10 -10
- package/dist/lib/format.js +1 -1
- package/dist/lib/getConsumerRuntimeConfig.js +4 -4
- package/dist/lib/io.js +6 -6
- package/dist/lib/misc.d.ts +1 -1
- package/dist/lib/misc.js +5 -5
- package/dist/lib/resolve.js +2 -2
- package/dist/lib/roots.js +5 -5
- package/dist/lib/runWebpack.js +2 -2
- package/dist/lib/terminal.js +1 -1
- package/dist/main.js +5 -1
- package/dist/utils/hooks.js +3 -3
- package/gdu.d.ts +8 -1
- package/package.json +14 -7
package/dist/cli.js
CHANGED
|
@@ -8,18 +8,18 @@ const tapable_1 = require("tapable");
|
|
|
8
8
|
const commands_1 = __importDefault(require("./commands"));
|
|
9
9
|
require("./polyfill");
|
|
10
10
|
const hooks_1 = require("./utils/hooks");
|
|
11
|
-
const app = sade_1.default('gdu').option('--debug', 'Enable debug mode');
|
|
12
|
-
commands_1.default(app);
|
|
11
|
+
const app = (0, sade_1.default)('gdu').option('--debug', 'Enable debug mode');
|
|
12
|
+
(0, commands_1.default)(app);
|
|
13
13
|
exports.default = (argv) => {
|
|
14
|
-
hooks_1.registerHooks({
|
|
14
|
+
(0, hooks_1.registerHooks)({
|
|
15
15
|
webpackConfig: new tapable_1.SyncWaterfallHook(['config']),
|
|
16
16
|
babelConfig: new tapable_1.SyncWaterfallHook(['config']),
|
|
17
17
|
});
|
|
18
|
-
hooks_1.registerHooks({
|
|
18
|
+
(0, hooks_1.registerHooks)({
|
|
19
19
|
beforeServer: new tapable_1.AsyncSeriesWaterfallHook(['server']),
|
|
20
20
|
afterServer: new tapable_1.AsyncSeriesWaterfallHook(['server']),
|
|
21
21
|
});
|
|
22
|
-
hooks_1.registerHooks({
|
|
22
|
+
(0, hooks_1.registerHooks)({
|
|
23
23
|
nextJSPrepare: new tapable_1.AsyncSeriesWaterfallHook(['app']),
|
|
24
24
|
nextJSConfig: new tapable_1.SyncWaterfallHook(['config']),
|
|
25
25
|
});
|
|
@@ -9,10 +9,10 @@ const webpack_config_1 = __importDefault(require("../../config/webpack/webpack.c
|
|
|
9
9
|
const runWebpack_1 = require("../../lib/runWebpack");
|
|
10
10
|
const hooks_1 = require("../../utils/hooks");
|
|
11
11
|
const buildSPA = async (guruConfig) => {
|
|
12
|
-
const hooks = hooks_1.getHooks();
|
|
13
|
-
const webpackConfigs = hooks.webpackConfig.call(webpack_config_1.default());
|
|
14
|
-
const compiler = webpack_1.default(webpackConfigs);
|
|
15
|
-
runWebpack_1.run(compiler);
|
|
12
|
+
const hooks = (0, hooks_1.getHooks)();
|
|
13
|
+
const webpackConfigs = hooks.webpackConfig.call((0, webpack_config_1.default)());
|
|
14
|
+
const compiler = (0, webpack_1.default)(webpackConfigs);
|
|
15
|
+
(0, runWebpack_1.run)(compiler);
|
|
16
16
|
return {
|
|
17
17
|
artifactPath: guruConfig.outputPath,
|
|
18
18
|
};
|
|
@@ -9,7 +9,7 @@ const utilities_1 = require("@autoguru/utilities");
|
|
|
9
9
|
const execa_1 = __importDefault(require("execa"));
|
|
10
10
|
const kleur_1 = require("kleur");
|
|
11
11
|
const roots_1 = require("../../lib/roots");
|
|
12
|
-
const logger = utilities_1.createLogger('build');
|
|
12
|
+
const logger = (0, utilities_1.createLogger)('build');
|
|
13
13
|
const buildSSR = async (guruConfig) => {
|
|
14
14
|
const start = Date.now();
|
|
15
15
|
execa_1.default
|
|
@@ -24,7 +24,7 @@ const buildSSR = async (guruConfig) => {
|
|
|
24
24
|
},
|
|
25
25
|
})
|
|
26
26
|
.then((result) => {
|
|
27
|
-
console.log(`${kleur_1.dim('SUCCESS!')}`, `${kleur_1.dim('Listening')}: ${kleur_1.blue(result === null || result === void 0 ? void 0 : result.all)}`);
|
|
27
|
+
console.log(`${(0, kleur_1.dim)('SUCCESS!')}`, `${(0, kleur_1.dim)('Listening')}: ${(0, kleur_1.blue)(result === null || result === void 0 ? void 0 : result.all)}`);
|
|
28
28
|
}, (error) => {
|
|
29
29
|
logger.error('response', {
|
|
30
30
|
processingTime: Date.now() - start,
|
|
@@ -35,7 +35,7 @@ const buildSSR = async (guruConfig) => {
|
|
|
35
35
|
throw error;
|
|
36
36
|
});
|
|
37
37
|
return {
|
|
38
|
-
artifactPath: path_1.join(guruConfig.outputPath, 'BUILD_ID'),
|
|
38
|
+
artifactPath: (0, path_1.join)(guruConfig.outputPath, 'BUILD_ID'),
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
41
|
exports.buildSSR = buildSSR;
|
|
@@ -9,21 +9,21 @@ const generateBrowsers_1 = require("../generateBrowsers");
|
|
|
9
9
|
const buildSPA_1 = require("./buildSPA");
|
|
10
10
|
const buildSSR_1 = require("./buildSSR");
|
|
11
11
|
exports.default = async () => {
|
|
12
|
-
misc_1.setEnvProd(true);
|
|
13
|
-
const guruConfig = config_1.getGuruConfig();
|
|
14
|
-
banner_1.banner('Building');
|
|
15
|
-
await generateBrowsers_1.buildSupportedBrowsers();
|
|
12
|
+
(0, misc_1.setEnvProd)(true);
|
|
13
|
+
const guruConfig = (0, config_1.getGuruConfig)();
|
|
14
|
+
(0, banner_1.banner)('Building');
|
|
15
|
+
await (0, generateBrowsers_1.buildSupportedBrowsers)();
|
|
16
16
|
let stats;
|
|
17
17
|
if ((guruConfig === null || guruConfig === void 0 ? void 0 : guruConfig.type) === 'ssr') {
|
|
18
|
-
stats = await buildSSR_1.buildSSR(guruConfig);
|
|
18
|
+
stats = await (0, buildSSR_1.buildSSR)(guruConfig);
|
|
19
19
|
}
|
|
20
20
|
else if ((guruConfig === null || guruConfig === void 0 ? void 0 : guruConfig.type) === 'spa') {
|
|
21
|
-
stats = await buildSPA_1.buildSPA(guruConfig);
|
|
21
|
+
stats = await (0, buildSPA_1.buildSPA)(guruConfig);
|
|
22
22
|
}
|
|
23
23
|
if (typeof stats !== 'undefined') {
|
|
24
|
-
githubOutputs_1.genGithubOutputs({
|
|
24
|
+
(0, githubOutputs_1.genGithubOutputs)({
|
|
25
25
|
artifact_path: stats.artifactPath,
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
|
-
terminal_1.projectInfo('Done ✅');
|
|
28
|
+
(0, terminal_1.projectInfo)('Done ✅');
|
|
29
29
|
};
|
|
@@ -4,8 +4,8 @@ const configure_1 = require("../../lib/configure");
|
|
|
4
4
|
const main_1 = require("../../main");
|
|
5
5
|
const hooks_1 = require("../../utils/hooks");
|
|
6
6
|
exports.default = async () => {
|
|
7
|
-
hooks_1.bindHooks();
|
|
8
|
-
for (const app of await main_1.getApps()) {
|
|
9
|
-
await configure_1.configure(app);
|
|
7
|
+
(0, hooks_1.bindHooks)();
|
|
8
|
+
for (const app of await (0, main_1.getApps)()) {
|
|
9
|
+
await (0, configure_1.configure)(app);
|
|
10
10
|
}
|
|
11
11
|
};
|
package/dist/commands/format.js
CHANGED
|
@@ -8,13 +8,13 @@ const kleur_1 = require("kleur");
|
|
|
8
8
|
const resolve_1 = require("../lib/resolve");
|
|
9
9
|
const roots_1 = require("../lib/roots");
|
|
10
10
|
exports.default = (options) => {
|
|
11
|
-
console.log(`${kleur_1.cyan('Formatting with prettier...')}`);
|
|
11
|
+
console.log(`${(0, kleur_1.cyan)('Formatting with prettier...')}`);
|
|
12
12
|
const shouldWrite = options['list-different'] === 'false' && options.write === 'true';
|
|
13
|
-
execa_1.default('prettier', [
|
|
13
|
+
(0, execa_1.default)('prettier', [
|
|
14
14
|
'--config',
|
|
15
15
|
require.resolve('../config/prettierConfig.js'),
|
|
16
16
|
'--ignore-path',
|
|
17
|
-
resolve_1.resolvePathFromCaller('.prettierignore'),
|
|
17
|
+
(0, resolve_1.resolvePathFromCaller)('.prettierignore'),
|
|
18
18
|
shouldWrite ? '--write' : '-l',
|
|
19
19
|
'**/*.+(js|jsx|ts|tsx|css|scss|json|yml|gql|graphql|md|mdx)',
|
|
20
20
|
], {
|
|
@@ -6,13 +6,13 @@ const kleur_1 = require("kleur");
|
|
|
6
6
|
const configure_1 = require("../lib/configure");
|
|
7
7
|
const io_1 = require("../lib/io");
|
|
8
8
|
const buildSupportedBrowsers = async () => {
|
|
9
|
-
console.log(`${kleur_1.green('Building supported browsers list')}`);
|
|
10
|
-
const regExp = browserslist_useragent_regexp_1.getUserAgentRegExp({
|
|
9
|
+
console.log(`${(0, kleur_1.green)('Building supported browsers list')}`);
|
|
10
|
+
const regExp = (0, browserslist_useragent_regexp_1.getUserAgentRegExp)({
|
|
11
11
|
allowHigherVersions: true,
|
|
12
12
|
});
|
|
13
|
-
await io_1.writeFileAsync('browsers.ts', configure_1.WRAP_BANNER(`export const AGSupportedBrowsers = ${regExp}`));
|
|
13
|
+
await (0, io_1.writeFileAsync)('browsers.ts', (0, configure_1.WRAP_BANNER)(`export const AGSupportedBrowsers = ${regExp}`));
|
|
14
14
|
};
|
|
15
15
|
exports.buildSupportedBrowsers = buildSupportedBrowsers;
|
|
16
16
|
exports.default = async () => {
|
|
17
|
-
await exports.buildSupportedBrowsers();
|
|
17
|
+
await (0, exports.buildSupportedBrowsers)();
|
|
18
18
|
};
|
|
@@ -4,7 +4,7 @@ const date_fns_1 = require("date-fns");
|
|
|
4
4
|
exports.default = () => {
|
|
5
5
|
const envOutput = {
|
|
6
6
|
safe_branch_name: getBranchName(),
|
|
7
|
-
versioned_release_name: `${date_fns_1.format(new Date(), 'yyyy.MM.dd-HHmmss')}+${getBranchName()}`,
|
|
7
|
+
versioned_release_name: `${(0, date_fns_1.format)(new Date(), 'yyyy.MM.dd-HHmmss')}+${getBranchName()}`,
|
|
8
8
|
};
|
|
9
9
|
Object.entries(envOutput).forEach(([key, value]) => console.log(`::set-env name=gdu__${key}::${value}`));
|
|
10
10
|
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const http_1 = __importDefault(require("http"));
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
const execa_1 = __importDefault(require("execa"));
|
|
9
|
+
const graphql_config_1 = require("graphql-config");
|
|
10
|
+
const kleur_1 = require("kleur");
|
|
11
|
+
const node_static_1 = require("node-static");
|
|
12
|
+
const open_1 = __importDefault(require("open"));
|
|
13
|
+
const roots_1 = require("../lib/roots");
|
|
14
|
+
const graphqlSchema_1 = __importDefault(require("./graphqlSchema"));
|
|
15
|
+
exports.default = async (options) => {
|
|
16
|
+
const graphQLConfig = await (0, graphql_config_1.loadConfig)({
|
|
17
|
+
rootDir: roots_1.PROJECT_ROOT,
|
|
18
|
+
});
|
|
19
|
+
const config = graphQLConfig.getDefault();
|
|
20
|
+
const compareEndpointConfig = config.extension('endpoints')[options.endpoint];
|
|
21
|
+
if (typeof compareEndpointConfig === 'undefined') {
|
|
22
|
+
throw new TypeError(`Compare Endpoint ${options.endpoint} doesnt exist use -c flag to pass you compare endpoint name`);
|
|
23
|
+
}
|
|
24
|
+
const path = config.schema;
|
|
25
|
+
const folderIndex = path.lastIndexOf('/');
|
|
26
|
+
const schemaPath = options.schemaPath || path;
|
|
27
|
+
await (0, graphqlSchema_1.default)({
|
|
28
|
+
...options,
|
|
29
|
+
s: schemaPath,
|
|
30
|
+
schemaPath,
|
|
31
|
+
});
|
|
32
|
+
const folderPath = path.slice(0, folderIndex + 1);
|
|
33
|
+
const compareSchemaPath = options.compareSchemaPath ||
|
|
34
|
+
`${folderPath}compare-${path.slice(folderIndex + 1, path.length)}`;
|
|
35
|
+
await (0, graphqlSchema_1.default)({
|
|
36
|
+
...options,
|
|
37
|
+
e: options.c,
|
|
38
|
+
endpoint: options.compareEndpoint,
|
|
39
|
+
s: compareSchemaPath,
|
|
40
|
+
schemaPath: compareSchemaPath,
|
|
41
|
+
});
|
|
42
|
+
execa_1.default
|
|
43
|
+
.command(`graphql-schema-diff ${compareSchemaPath} ${schemaPath} --create-html-output`, {
|
|
44
|
+
stdio: 'inherit',
|
|
45
|
+
cwd: roots_1.PROJECT_ROOT,
|
|
46
|
+
localDir: roots_1.PROJECT_ROOT,
|
|
47
|
+
extendEnv: true,
|
|
48
|
+
})
|
|
49
|
+
.then((result) => {
|
|
50
|
+
console.log(`${(0, kleur_1.green)('SUCCESS!')}`, result);
|
|
51
|
+
console.log(`${(0, kleur_1.green)('Schemas Diff document generated under')} ${(0, kleur_1.blue)('./schemaDiff/index.html')}`);
|
|
52
|
+
const staticSitePath = (0, path_1.join)(roots_1.PROJECT_ROOT, 'schemaDiff');
|
|
53
|
+
const file = new node_static_1.Server(staticSitePath);
|
|
54
|
+
const port = options.port || 8080;
|
|
55
|
+
const url = `http://localhost:${port}`;
|
|
56
|
+
http_1.default.createServer(function (request, response) {
|
|
57
|
+
request
|
|
58
|
+
.addListener('end', function () {
|
|
59
|
+
file.serve(request, response);
|
|
60
|
+
})
|
|
61
|
+
.resume();
|
|
62
|
+
}).listen(port);
|
|
63
|
+
console.log(`View diff under ${url}`);
|
|
64
|
+
(0, open_1.default)(url);
|
|
65
|
+
}, (error) => {
|
|
66
|
+
throw error;
|
|
67
|
+
});
|
|
68
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const http_1 = __importDefault(require("http"));
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
const execa_1 = __importDefault(require("execa"));
|
|
9
|
+
const graphql_config_1 = require("graphql-config");
|
|
10
|
+
const kleur_1 = require("kleur");
|
|
11
|
+
const node_static_1 = require("node-static");
|
|
12
|
+
const open_1 = __importDefault(require("open"));
|
|
13
|
+
const roots_1 = require("../lib/roots");
|
|
14
|
+
const graphqlSchema_1 = __importDefault(require("./graphqlSchema"));
|
|
15
|
+
exports.default = async (options) => {
|
|
16
|
+
const graphQLConfig = await (0, graphql_config_1.loadConfig)({
|
|
17
|
+
rootDir: roots_1.PROJECT_ROOT,
|
|
18
|
+
});
|
|
19
|
+
const config = graphQLConfig.getDefault();
|
|
20
|
+
const compareEndpointConfig = config.extension('endpoints')[options.endpoint];
|
|
21
|
+
if (typeof compareEndpointConfig === 'undefined') {
|
|
22
|
+
throw new TypeError(`Compare Endpoint ${options.endpoint} doesnt exist use -c flag to pass you compare endpoint name`);
|
|
23
|
+
}
|
|
24
|
+
const path = config.schema;
|
|
25
|
+
const schemaPath = options.schemaPath || path;
|
|
26
|
+
await (0, graphqlSchema_1.default)({
|
|
27
|
+
...options,
|
|
28
|
+
s: schemaPath,
|
|
29
|
+
schemaPath,
|
|
30
|
+
});
|
|
31
|
+
execa_1.default
|
|
32
|
+
.command(`graphdoc -s ${schemaPath} -o ./doc/schema --force`, {
|
|
33
|
+
stdio: 'inherit',
|
|
34
|
+
cwd: roots_1.PROJECT_ROOT,
|
|
35
|
+
localDir: roots_1.PROJECT_ROOT,
|
|
36
|
+
extendEnv: true,
|
|
37
|
+
})
|
|
38
|
+
.then((result) => {
|
|
39
|
+
console.log(`${(0, kleur_1.green)('SUCCESS!')}`, result);
|
|
40
|
+
console.log(`${(0, kleur_1.green)('Schema docs generated under')} ${(0, kleur_1.blue)('./doc/schema')}`);
|
|
41
|
+
const staticSitePath = (0, path_1.join)(roots_1.PROJECT_ROOT, 'doc', 'schema');
|
|
42
|
+
const file = new node_static_1.Server(staticSitePath);
|
|
43
|
+
const port = options.port || 8080;
|
|
44
|
+
const url = `http://localhost:${port}`;
|
|
45
|
+
http_1.default.createServer(function (request, response) {
|
|
46
|
+
request
|
|
47
|
+
.addListener('end', function () {
|
|
48
|
+
file.serve(request, response);
|
|
49
|
+
})
|
|
50
|
+
.resume();
|
|
51
|
+
}).listen(port);
|
|
52
|
+
console.log(`View docs under ${url}`);
|
|
53
|
+
(0, open_1.default)(url);
|
|
54
|
+
}, (error) => {
|
|
55
|
+
throw error;
|
|
56
|
+
});
|
|
57
|
+
};
|
|
@@ -1,2 +1,13 @@
|
|
|
1
|
+
import { GraphQLConfigExtension } from 'graphql-config/extension';
|
|
2
|
+
export interface EndpointExtension extends GraphQLConfigExtension {
|
|
3
|
+
url: string;
|
|
4
|
+
method: 'GET' | 'POST';
|
|
5
|
+
headers: Record<string, string>;
|
|
6
|
+
schemaNormaliserPatterns: Array<{
|
|
7
|
+
pattern: string;
|
|
8
|
+
flags?: string;
|
|
9
|
+
replacer: string;
|
|
10
|
+
}>;
|
|
11
|
+
}
|
|
1
12
|
declare const _default: (options: any) => Promise<void>;
|
|
2
13
|
export default _default;
|
|
@@ -7,11 +7,16 @@ const graphql_config_1 = require("graphql-config");
|
|
|
7
7
|
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
8
8
|
const io_1 = require("../lib/io");
|
|
9
9
|
const roots_1 = require("../lib/roots");
|
|
10
|
-
const normalise = (patterns, rawSchema) =>
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const normalise = (patterns, rawSchema) => {
|
|
11
|
+
if (typeof rawSchema !== 'string')
|
|
12
|
+
return rawSchema;
|
|
13
|
+
const schema = rawSchema.replaceAll('`', "'");
|
|
14
|
+
return Array.isArray(patterns)
|
|
15
|
+
? patterns.reduce((schemaStr, normaliser) => schemaStr.replace(new RegExp(normaliser.pattern, normaliser.flags), normaliser.replacer), schema)
|
|
16
|
+
: schema;
|
|
17
|
+
};
|
|
13
18
|
exports.default = async (options) => {
|
|
14
|
-
const graphQLConfig = await graphql_config_1.loadConfig({
|
|
19
|
+
const graphQLConfig = await (0, graphql_config_1.loadConfig)({
|
|
15
20
|
rootDir: roots_1.CALLING_WORKSPACE_ROOT,
|
|
16
21
|
});
|
|
17
22
|
const config = graphQLConfig.getDefault();
|
|
@@ -19,12 +24,12 @@ exports.default = async (options) => {
|
|
|
19
24
|
if (typeof endpointConfig === 'undefined') {
|
|
20
25
|
throw new TypeError(`Endpoint ${options.endpoint} doesnt exist`);
|
|
21
26
|
}
|
|
22
|
-
const response = await node_fetch_1.default(endpointConfig.url, {
|
|
27
|
+
const response = await (0, node_fetch_1.default)(endpointConfig.url, {
|
|
23
28
|
method: endpointConfig.method,
|
|
24
29
|
headers: endpointConfig.headers,
|
|
25
30
|
});
|
|
26
31
|
if ((response === null || response === void 0 ? void 0 : response.ok) || (response === null || response === void 0 ? void 0 : response.body)) {
|
|
27
|
-
await io_1.writeFileAsync(config.schema, normalise(endpointConfig.schemaNormaliserPatterns, await response.text()));
|
|
32
|
+
await (0, io_1.writeFileAsync)(options.schemaPath || config.schema, normalise(endpointConfig.schemaNormaliserPatterns, await response.text()));
|
|
28
33
|
}
|
|
29
34
|
console.log('~> Schema has been checked, and is ready to use! ✅️');
|
|
30
35
|
};
|
package/dist/commands/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -22,13 +26,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
22
26
|
const config_1 = require("../lib/config");
|
|
23
27
|
const misc_1 = require("../lib/misc");
|
|
24
28
|
const hooks_1 = require("../utils/hooks");
|
|
25
|
-
const deferredAction = (importee, shouldRun) => misc_1.wrapAction((...args) => {
|
|
29
|
+
const deferredAction = (importee, shouldRun) => (0, misc_1.wrapAction)((...args) => {
|
|
26
30
|
if (typeof shouldRun === 'function') {
|
|
27
|
-
const guruConfig = config_1.getGuruConfig();
|
|
31
|
+
const guruConfig = (0, config_1.getGuruConfig)();
|
|
28
32
|
if (shouldRun(guruConfig) === false)
|
|
29
33
|
throw new Error('Sorry this command is not supported');
|
|
30
34
|
}
|
|
31
|
-
hooks_1.bindHooks();
|
|
35
|
+
(0, hooks_1.bindHooks)();
|
|
32
36
|
return importee().then((item) => {
|
|
33
37
|
return item.default(...args);
|
|
34
38
|
});
|
|
@@ -61,15 +65,30 @@ exports.default = (app) => {
|
|
|
61
65
|
.action(deferredAction(async () => Promise.resolve().then(() => __importStar(require('./format'))), IS_NOT_ROOT));
|
|
62
66
|
app.command('graphql-schema')
|
|
63
67
|
.option('-e, --endpoint', 'The endpoint name to retrieve the schema from.')
|
|
68
|
+
.option('-s, --schemaPath', 'The path to write schema file to.')
|
|
64
69
|
.example('graphql-schema')
|
|
65
70
|
.action(deferredAction(async () => Promise.resolve().then(() => __importStar(require('./graphqlSchema')))));
|
|
71
|
+
app.command('graphql-doc')
|
|
72
|
+
.option('-e, --endpoint', 'The endpoint name to retrieve the schema from.')
|
|
73
|
+
.option('-s, --schemaPath', 'The path to write schema file to.')
|
|
74
|
+
.option('-p, --port', 'Port number to serve the docs over.')
|
|
75
|
+
.example('graphql-schema')
|
|
76
|
+
.action(deferredAction(async () => Promise.resolve().then(() => __importStar(require('./graphqlDoc')))));
|
|
77
|
+
app.command('graphql-diff')
|
|
78
|
+
.option('-e, --endpoint', 'The endpoint name to retrieve the schema from.')
|
|
79
|
+
.option('-s, --schemaPath', 'The path to write schema file to.')
|
|
80
|
+
.option('-c, --compareEndpoint', 'The endpoint name to retrieve compare schema from.')
|
|
81
|
+
.option('-cs, --compareSchemaPath', 'The path to write schema file to.')
|
|
82
|
+
.option('-p, --port', 'Port number to serve the diff over.')
|
|
83
|
+
.example('graphql-diff')
|
|
84
|
+
.action(deferredAction(async () => Promise.resolve().then(() => __importStar(require('./graphqlDiff')))));
|
|
66
85
|
app.command('test').action(NOT_READY);
|
|
67
86
|
app.command('lint').action(NOT_READY);
|
|
68
87
|
app.command('gh-actions')
|
|
69
88
|
.describe('A command to create GitHub actions things')
|
|
70
89
|
.action(deferredAction(async () => Promise.resolve().then(() => __importStar(require('./gh-actions')))));
|
|
71
90
|
};
|
|
72
|
-
const NOT_READY = misc_1.wrapAction(() => {
|
|
91
|
+
const NOT_READY = (0, misc_1.wrapAction)(() => {
|
|
73
92
|
throw new Error('No ready yet');
|
|
74
93
|
});
|
|
75
94
|
const IS_NOT_ROOT = (config) => {
|
|
@@ -12,7 +12,7 @@ const banner_1 = require("../lib/banner");
|
|
|
12
12
|
const configure_1 = require("../lib/configure");
|
|
13
13
|
const io_1 = require("../lib/io");
|
|
14
14
|
const roots_1 = require("../lib/roots");
|
|
15
|
-
const { debug } = diary_1.diary('gdu:commands:scaffold');
|
|
15
|
+
const { debug } = (0, diary_1.diary)('gdu:commands:scaffold');
|
|
16
16
|
const availableTypes = ['ssr', 'spa'];
|
|
17
17
|
const validateOptions = ({ type }) => {
|
|
18
18
|
if (!availableTypes.includes(type)) {
|
|
@@ -20,15 +20,15 @@ const validateOptions = ({ type }) => {
|
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
const ensureAppFolder = async (app_name) => {
|
|
23
|
-
const appFolder = path_1.join(roots_1.PROJECT_ROOT, `apps/${app_name}/`);
|
|
23
|
+
const appFolder = (0, path_1.join)(roots_1.PROJECT_ROOT, `apps/${app_name}/`);
|
|
24
24
|
debug('scaffolding into %s', appFolder);
|
|
25
|
-
if (fs_1.existsSync(appFolder))
|
|
25
|
+
if ((0, fs_1.existsSync)(appFolder))
|
|
26
26
|
throw new Error(`Target app ${appFolder} already exists!`);
|
|
27
|
-
await io_1.mkdirpAsync(appFolder);
|
|
27
|
+
await (0, io_1.mkdirpAsync)(appFolder);
|
|
28
28
|
return appFolder;
|
|
29
29
|
};
|
|
30
30
|
const baseAppScaff = async (options, outputFiles) => {
|
|
31
|
-
const configFile = ts_dedent_1.default `module.exports = {
|
|
31
|
+
const configFile = (0, ts_dedent_1.default) `module.exports = {
|
|
32
32
|
type: ${options.type === 'ssr' ? "'ssr'" : "'spa'"},
|
|
33
33
|
};`;
|
|
34
34
|
outputFiles.set('guru.config.js', configFile);
|
|
@@ -62,18 +62,18 @@ exports.default = async (type, app_name) => {
|
|
|
62
62
|
const options = { type, app_name };
|
|
63
63
|
debug('running action with %O', options);
|
|
64
64
|
validateOptions(options);
|
|
65
|
-
banner_1.banner('Creating', `@autoguru/${app_name}`);
|
|
65
|
+
(0, banner_1.banner)('Creating', `@autoguru/${app_name}`);
|
|
66
66
|
const outputPath = await (options.type === 'spa'
|
|
67
67
|
? genSPA(options)
|
|
68
68
|
: genSSR(options));
|
|
69
|
-
await configure_1.configure(outputPath);
|
|
70
|
-
console.log(kleur_1.green('Done!'));
|
|
69
|
+
await (0, configure_1.configure)(outputPath);
|
|
70
|
+
console.log((0, kleur_1.green)('Done!'));
|
|
71
71
|
};
|
|
72
72
|
const genSPA = async (options) => {
|
|
73
73
|
const appFolder = await ensureAppFolder(options.app_name);
|
|
74
74
|
const writeFiles = new Map();
|
|
75
75
|
await baseAppScaff(options, writeFiles);
|
|
76
|
-
writeFiles.set('src/App/index.tsx', ts_dedent_1.default `import * as React from 'react';
|
|
76
|
+
writeFiles.set('src/App/index.tsx', (0, ts_dedent_1.default) `import * as React from 'react';
|
|
77
77
|
import '@autoguru/overdrive/reset';
|
|
78
78
|
|
|
79
79
|
import { baseTheme } from '@autoguru/overdrive/themes';
|
|
@@ -86,29 +86,29 @@ const genSPA = async (options) => {
|
|
|
86
86
|
</OverdriveProvider>
|
|
87
87
|
);
|
|
88
88
|
`);
|
|
89
|
-
writeFiles.set('src/scenes/index.tsx', ts_dedent_1.default `import * as React from 'react';
|
|
89
|
+
writeFiles.set('src/scenes/index.tsx', (0, ts_dedent_1.default) `import * as React from 'react';
|
|
90
90
|
import { Heading } from '@autoguru/overdrive';
|
|
91
91
|
|
|
92
92
|
export default () => <Heading is="h1">Welcome to your new SPA application!</Heading>
|
|
93
93
|
`);
|
|
94
|
-
writeFiles.set('src/client.tsx', ts_dedent_1.default `import * as React from 'react';
|
|
94
|
+
writeFiles.set('src/client.tsx', (0, ts_dedent_1.default) `import * as React from 'react';
|
|
95
95
|
import { render } from 'react-dom';
|
|
96
96
|
import App from './App';
|
|
97
97
|
|
|
98
98
|
export default () => void render(<App />, document.getElementById('app'));
|
|
99
99
|
`);
|
|
100
|
-
await io_1.writeFileMap(writeFiles, appFolder);
|
|
100
|
+
await (0, io_1.writeFileMap)(writeFiles, appFolder);
|
|
101
101
|
return appFolder;
|
|
102
102
|
};
|
|
103
103
|
const genSSR = async (options) => {
|
|
104
104
|
const appFolder = await ensureAppFolder(options.app_name);
|
|
105
105
|
const writeFiles = new Map();
|
|
106
106
|
await baseAppScaff(options, writeFiles);
|
|
107
|
-
writeFiles.set('pages/index.tsx', ts_dedent_1.default `
|
|
107
|
+
writeFiles.set('pages/index.tsx', (0, ts_dedent_1.default) `
|
|
108
108
|
import React from 'react';
|
|
109
109
|
import { Heading } from '@autoguru/overdrive';
|
|
110
110
|
|
|
111
111
|
export default () => <Heading is="h1">Welcome to your new SSR application!</Heading>;`);
|
|
112
|
-
await io_1.writeFileMap(writeFiles, appFolder);
|
|
112
|
+
await (0, io_1.writeFileMap)(writeFiles, appFolder);
|
|
113
113
|
return appFolder;
|
|
114
114
|
};
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -25,14 +29,14 @@ const config_1 = require("../../lib/config");
|
|
|
25
29
|
const misc_1 = require("../../lib/misc");
|
|
26
30
|
const roots_1 = require("../../lib/roots");
|
|
27
31
|
const generateBrowsers_1 = require("../generateBrowsers");
|
|
28
|
-
const { debug } = diary_1.diary('gdu:commands:start');
|
|
32
|
+
const { debug } = (0, diary_1.diary)('gdu:commands:start');
|
|
29
33
|
exports.default = async ({ port: incomingPort }) => {
|
|
30
34
|
debug('running action with %O', { port: incomingPort });
|
|
31
|
-
const { port = incomingPort, ...otherConfig } = config_1.getGuruConfig(roots_1.PROJECT_ROOT) || {};
|
|
35
|
+
const { port = incomingPort, ...otherConfig } = (0, config_1.getGuruConfig)(roots_1.PROJECT_ROOT) || {};
|
|
32
36
|
const resolvedConfig = { port, ...otherConfig };
|
|
33
|
-
await generateBrowsers_1.buildSupportedBrowsers();
|
|
34
|
-
if (!misc_1.
|
|
35
|
-
banner_1.banner('Starting');
|
|
37
|
+
await (0, generateBrowsers_1.buildSupportedBrowsers)();
|
|
38
|
+
if (!(0, misc_1.isProductionBuild)())
|
|
39
|
+
(0, banner_1.banner)('Starting');
|
|
36
40
|
if ((resolvedConfig === null || resolvedConfig === void 0 ? void 0 : resolvedConfig.type) === 'ssr') {
|
|
37
41
|
const runSSR = await Promise.resolve().then(() => __importStar(require('./runSSR')));
|
|
38
42
|
await runSSR.runNextJS(resolvedConfig);
|
|
@@ -17,8 +17,8 @@ const roots_1 = require("../../lib/roots");
|
|
|
17
17
|
const hooks_1 = require("../../utils/hooks");
|
|
18
18
|
const getConsumerHtmlTemplate = (guruConfig) => {
|
|
19
19
|
try {
|
|
20
|
-
const filePath = path_1.join(guruConfig.__configPath, '/template.html');
|
|
21
|
-
if (fs_1.existsSync(filePath)) {
|
|
20
|
+
const filePath = (0, path_1.join)(guruConfig.__configPath, '/template.html');
|
|
21
|
+
if ((0, fs_1.existsSync)(filePath)) {
|
|
22
22
|
return filePath;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -29,11 +29,11 @@ const getConsumerHtmlTemplate = (guruConfig) => {
|
|
|
29
29
|
const localhost = '0.0.0.0';
|
|
30
30
|
const hosts = ['localhost', localhost];
|
|
31
31
|
const runSPA = async (guruConfig) => {
|
|
32
|
-
const hooks = hooks_1.getHooks();
|
|
33
|
-
console.log(`${kleur_1.cyan('Starting dev server...')}`);
|
|
32
|
+
const hooks = (0, hooks_1.getHooks)();
|
|
33
|
+
console.log(`${(0, kleur_1.cyan)('Starting dev server...')}`);
|
|
34
34
|
const appEnv = process.env.APP_ENV || 'dev';
|
|
35
35
|
const webpackConfig = hooks.webpackConfig
|
|
36
|
-
.call(webpack_config_1.default())
|
|
36
|
+
.call((0, webpack_config_1.default)())
|
|
37
37
|
.find(({ name }) => name === appEnv);
|
|
38
38
|
const consumerHtmlTemplate = getConsumerHtmlTemplate(guruConfig);
|
|
39
39
|
webpackConfig.plugins.push(new html_webpack_plugin_1.default({
|
|
@@ -73,26 +73,26 @@ const runSPA = async (guruConfig) => {
|
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
})());
|
|
76
|
-
const compiler = webpack_1.default(webpackConfig);
|
|
76
|
+
const compiler = (0, webpack_1.default)(webpackConfig);
|
|
77
77
|
let beenReadyBefore = false;
|
|
78
78
|
compiler.hooks.done.tap('runner', () => {
|
|
79
79
|
if (!beenReadyBefore) {
|
|
80
|
-
console.log(ts_dedent_1.default `
|
|
80
|
+
console.log((0, ts_dedent_1.default) `
|
|
81
81
|
|
|
82
|
-
You can now view ${kleur_1.bold(config_1.getProjectName())} in the browser.
|
|
82
|
+
You can now view ${(0, kleur_1.bold)((0, config_1.getProjectName)())} in the browser.
|
|
83
83
|
|
|
84
|
-
Local: ${kleur_1.blue(`http://${hosts[0]}:${guruConfig.port}/`)}
|
|
85
|
-
On Your Network: ${kleur_1.blue(`http://${require('ip').address()}:${guruConfig.port}/`)}
|
|
84
|
+
Local: ${(0, kleur_1.blue)(`http://${hosts[0]}:${guruConfig.port}/`)}
|
|
85
|
+
On Your Network: ${(0, kleur_1.blue)(`http://${require('ip').address()}:${guruConfig.port}/`)}
|
|
86
86
|
|
|
87
87
|
Note that the development build is not optimized.
|
|
88
|
-
To create a production build, use ${kleur_1.cyan('yarn build')}.
|
|
88
|
+
To create a production build, use ${(0, kleur_1.cyan)('yarn build')}.
|
|
89
89
|
|
|
90
90
|
`);
|
|
91
91
|
beenReadyBefore = true;
|
|
92
92
|
}
|
|
93
93
|
});
|
|
94
94
|
const devServer = new webpack_dev_server_1.default(compiler, {
|
|
95
|
-
static: path_1.join(roots_1.PROJECT_ROOT, 'public'),
|
|
95
|
+
static: (0, path_1.join)(roots_1.PROJECT_ROOT, 'public'),
|
|
96
96
|
host: hosts[0],
|
|
97
97
|
allowedHosts: hosts,
|
|
98
98
|
historyApiFallback: true,
|
|
@@ -100,7 +100,7 @@ const runSPA = async (guruConfig) => {
|
|
|
100
100
|
});
|
|
101
101
|
devServer.listen(guruConfig.port, localhost, (err) => {
|
|
102
102
|
if (err) {
|
|
103
|
-
console.log(kleur_1.red(err));
|
|
103
|
+
console.log((0, kleur_1.red)(err.message));
|
|
104
104
|
}
|
|
105
105
|
});
|
|
106
106
|
};
|
|
@@ -5,13 +5,13 @@ const diary_1 = require("diary");
|
|
|
5
5
|
const kleur_1 = require("kleur");
|
|
6
6
|
const server_1 = require("../../config/ssr/server");
|
|
7
7
|
const misc_1 = require("../../lib/misc");
|
|
8
|
-
const { debug } = diary_1.diary('gdu:commands:start:ssr');
|
|
8
|
+
const { debug } = (0, diary_1.diary)('gdu:commands:start:ssr');
|
|
9
9
|
const runNextJS = async (guruConfig) => {
|
|
10
10
|
var _a;
|
|
11
11
|
const port = (_a = guruConfig.port) !== null && _a !== void 0 ? _a : 8080;
|
|
12
12
|
debug('next start %o', { port });
|
|
13
|
-
if (!misc_1.
|
|
14
|
-
console.log(`${kleur_1.cyan('Starting dev server...')}`);
|
|
15
|
-
await server_1.run(port);
|
|
13
|
+
if (!(0, misc_1.isProductionBuild)())
|
|
14
|
+
console.log(`${(0, kleur_1.cyan)('Starting dev server...')}`);
|
|
15
|
+
await (0, server_1.run)(port);
|
|
16
16
|
};
|
|
17
17
|
exports.runNextJS = runNextJS;
|
|
@@ -14,14 +14,13 @@ export declare const createNextJSConfig: (buildEnv: any) => {
|
|
|
14
14
|
distDir: string;
|
|
15
15
|
reactStrictMode: boolean;
|
|
16
16
|
swcMinify: boolean;
|
|
17
|
+
poweredByHeader: boolean;
|
|
17
18
|
assetPrefix: string;
|
|
18
19
|
i18n: {
|
|
19
20
|
locales: string[];
|
|
20
21
|
defaultLocale: string;
|
|
21
22
|
};
|
|
22
23
|
typescript: {
|
|
23
|
-
transpileOnly: boolean;
|
|
24
|
-
ignoreDevErrors: boolean;
|
|
25
24
|
ignoreBuildErrors: boolean;
|
|
26
25
|
};
|
|
27
26
|
images: {
|