@hed-hog/cli 0.0.45 → 0.0.46
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/package.json +1 -1
- package/dist/src/modules/developer/developer.service.js +144 -103
- package/dist/src/modules/developer/developer.service.js.map +1 -1
- package/dist/src/templates/library/en.json.ejs +8 -1
- package/dist/src/templates/library/page.tsx.ejs +22 -6
- package/dist/src/templates/library/pt.json.ejs +8 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/package.json
CHANGED
|
@@ -2016,113 +2016,154 @@ ${config.setupSSL
|
|
|
2016
2016
|
return `${parsed.major}.${parsed.minor}.${parsed.patch + 1}`;
|
|
2017
2017
|
}
|
|
2018
2018
|
async createLibrary(path, libraryName, force = false, verbose = false, skipInstall = false) {
|
|
2019
|
+
const restoreWarnings = this.suppressWarnings();
|
|
2019
2020
|
this.verbose = verbose;
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
const libraryPath = pathModule.join(path, 'libraries', libraryName);
|
|
2026
|
-
if ((0, fs_1.existsSync)(libraryPath)) {
|
|
2027
|
-
if (force) {
|
|
2028
|
-
this.log(chalk.yellow(`Library ${libraryName} already exists. Overwriting...`));
|
|
2029
|
-
}
|
|
2030
|
-
else {
|
|
2031
|
-
console.error(chalk.red(`Library ${libraryName} already exists.`));
|
|
2021
|
+
const spinner = ora('Starting library creation...').start();
|
|
2022
|
+
try {
|
|
2023
|
+
this.log(chalk.blue('Starting library creation...'));
|
|
2024
|
+
if (!libraryName) {
|
|
2025
|
+
spinner.fail(chalk.red('Library name is required.'));
|
|
2032
2026
|
return;
|
|
2033
2027
|
}
|
|
2028
|
+
const libraryPath = pathModule.join(path, 'libraries', libraryName);
|
|
2029
|
+
if ((0, fs_1.existsSync)(libraryPath)) {
|
|
2030
|
+
if (force) {
|
|
2031
|
+
this.log(chalk.yellow(`Library ${libraryName} already exists. Overwriting...`));
|
|
2032
|
+
}
|
|
2033
|
+
else {
|
|
2034
|
+
spinner.fail(chalk.red(`Library ${libraryName} already exists.`));
|
|
2035
|
+
return;
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
spinner.text = `Creating base directory for ${libraryName}...`;
|
|
2039
|
+
await (0, promises_1.mkdir)(pathModule.join(libraryPath, 'src'), { recursive: true });
|
|
2040
|
+
spinner.succeed(chalk.green(`Created directory: ${libraryPath}/src`));
|
|
2041
|
+
const vars = {
|
|
2042
|
+
path,
|
|
2043
|
+
libraryPath,
|
|
2044
|
+
libraryNamePascalCase: this.toPascalCase(libraryName),
|
|
2045
|
+
libraryNameSnackCase: this.toSnackCase(libraryName),
|
|
2046
|
+
libraryNameCamelCase: this.toCamelCase(libraryName),
|
|
2047
|
+
libraryNameKebabCase: this.toKebabCase(libraryName),
|
|
2048
|
+
libraryName: libraryName,
|
|
2049
|
+
};
|
|
2050
|
+
const libraryFiles = [
|
|
2051
|
+
{
|
|
2052
|
+
template: '.eslintrc.js.ejs',
|
|
2053
|
+
destination: `/.eslintrc.js`,
|
|
2054
|
+
},
|
|
2055
|
+
{
|
|
2056
|
+
template: '.prettierrc.js.ejs',
|
|
2057
|
+
destination: `/.prettierrc.js`,
|
|
2058
|
+
},
|
|
2059
|
+
{
|
|
2060
|
+
template: 'package.json.ejs',
|
|
2061
|
+
destination: `/package.json`,
|
|
2062
|
+
},
|
|
2063
|
+
{
|
|
2064
|
+
template: 'tsconfig.json.ejs',
|
|
2065
|
+
destination: `/tsconfig.json`,
|
|
2066
|
+
},
|
|
2067
|
+
{
|
|
2068
|
+
template: 'tsconfig.production.json.ejs',
|
|
2069
|
+
destination: `/tsconfig.production.json`,
|
|
2070
|
+
},
|
|
2071
|
+
{
|
|
2072
|
+
template: 'module.ts.ejs',
|
|
2073
|
+
destination: `/src/${vars.libraryNameKebabCase}.module.ts`,
|
|
2074
|
+
},
|
|
2075
|
+
{
|
|
2076
|
+
template: 'index.ts.ejs',
|
|
2077
|
+
destination: `/src/index.ts`,
|
|
2078
|
+
},
|
|
2079
|
+
];
|
|
2080
|
+
const libraryLocalizationFiles = [
|
|
2081
|
+
{
|
|
2082
|
+
template: 'en.json.ejs',
|
|
2083
|
+
destination: `/src/language/en.json`,
|
|
2084
|
+
},
|
|
2085
|
+
{
|
|
2086
|
+
template: 'pt.json.ejs',
|
|
2087
|
+
destination: `/src/language/pt.json`,
|
|
2088
|
+
},
|
|
2089
|
+
];
|
|
2090
|
+
spinner.start('Criando arquivos da library...');
|
|
2091
|
+
for (const file of libraryFiles) {
|
|
2092
|
+
spinner.text = `Gerando ${file.template}...`;
|
|
2093
|
+
const templatePath = pathModule.join(__dirname, '..', '..', 'templates', 'library', file.template);
|
|
2094
|
+
const destinationPath = pathModule.join(path, 'libraries', libraryName, file.destination);
|
|
2095
|
+
await (0, promises_1.mkdir)(pathModule.dirname(destinationPath), { recursive: true });
|
|
2096
|
+
const content = await (0, promises_1.readFile)(templatePath, 'utf8');
|
|
2097
|
+
const renderedContent = await (0, ejs_1.render)(content, vars);
|
|
2098
|
+
await (0, promises_1.writeFile)(destinationPath, renderedContent, 'utf8');
|
|
2099
|
+
}
|
|
2100
|
+
spinner.succeed(chalk.green(`Arquivos da library criados com sucesso (${libraryFiles.length}).`));
|
|
2101
|
+
spinner.start('Atualizando tsconfig...');
|
|
2102
|
+
await this.updateTsconfigFiles(path, verbose);
|
|
2103
|
+
spinner.succeed(chalk.green('Tsconfig atualizado com sucesso.'));
|
|
2104
|
+
if (!skipInstall) {
|
|
2105
|
+
spinner.start(`Installing dependencies for ${libraryName}...`);
|
|
2106
|
+
await this.runner.executeCommand(runner_service_1.ProgramName.PNPM, ['install'], {
|
|
2107
|
+
cwd: libraryPath,
|
|
2108
|
+
}, true);
|
|
2109
|
+
spinner.succeed(chalk.green(`Dependencies installed for ${libraryName}.`));
|
|
2110
|
+
}
|
|
2111
|
+
const filesFrontend = [
|
|
2112
|
+
{
|
|
2113
|
+
template: 'page.tsx.ejs',
|
|
2114
|
+
destination: `/apps/admin/src/app/(app)/(library)/${vars.libraryNameKebabCase}/page.tsx`,
|
|
2115
|
+
},
|
|
2116
|
+
];
|
|
2117
|
+
const frontendLocalizationFiles = [
|
|
2118
|
+
{
|
|
2119
|
+
template: 'en.json.ejs',
|
|
2120
|
+
destination: `/apps/admin/messages/${vars.libraryNameKebabCase}/en.json`,
|
|
2121
|
+
},
|
|
2122
|
+
{
|
|
2123
|
+
template: 'pt.json.ejs',
|
|
2124
|
+
destination: `/apps/admin/messages/${vars.libraryNameKebabCase}/pt.json`,
|
|
2125
|
+
},
|
|
2126
|
+
];
|
|
2127
|
+
spinner.start('Criando arquivos do frontend...');
|
|
2128
|
+
for (const file of filesFrontend) {
|
|
2129
|
+
spinner.text = `Gerando ${file.template}...`;
|
|
2130
|
+
const templatePath = pathModule.join(__dirname, '..', '..', 'templates', 'library', file.template);
|
|
2131
|
+
const destinationPath = pathModule.join(path, file.destination);
|
|
2132
|
+
await (0, promises_1.mkdir)(pathModule.dirname(destinationPath), { recursive: true });
|
|
2133
|
+
const content = await (0, promises_1.readFile)(templatePath, 'utf8');
|
|
2134
|
+
const renderedContent = await (0, ejs_1.render)(content, vars);
|
|
2135
|
+
await (0, promises_1.writeFile)(destinationPath, renderedContent, 'utf8');
|
|
2136
|
+
}
|
|
2137
|
+
spinner.succeed(chalk.green(`Arquivos do frontend criados com sucesso (${filesFrontend.length}).`));
|
|
2138
|
+
spinner.start('Criando arquivos de localizacao...');
|
|
2139
|
+
for (const file of libraryLocalizationFiles) {
|
|
2140
|
+
spinner.text = `Gerando ${file.template} da library...`;
|
|
2141
|
+
const templatePath = pathModule.join(__dirname, '..', '..', 'templates', 'library', file.template);
|
|
2142
|
+
const destinationPath = pathModule.join(path, 'libraries', libraryName, file.destination);
|
|
2143
|
+
await (0, promises_1.mkdir)(pathModule.dirname(destinationPath), { recursive: true });
|
|
2144
|
+
const content = await (0, promises_1.readFile)(templatePath, 'utf8');
|
|
2145
|
+
const renderedContent = await (0, ejs_1.render)(content, vars);
|
|
2146
|
+
await (0, promises_1.writeFile)(destinationPath, renderedContent, 'utf8');
|
|
2147
|
+
}
|
|
2148
|
+
for (const file of frontendLocalizationFiles) {
|
|
2149
|
+
spinner.text = `Gerando ${file.template} do frontend...`;
|
|
2150
|
+
const templatePath = pathModule.join(__dirname, '..', '..', 'templates', 'library', file.template);
|
|
2151
|
+
const destinationPath = pathModule.join(path, file.destination);
|
|
2152
|
+
await (0, promises_1.mkdir)(pathModule.dirname(destinationPath), { recursive: true });
|
|
2153
|
+
const content = await (0, promises_1.readFile)(templatePath, 'utf8');
|
|
2154
|
+
const renderedContent = await (0, ejs_1.render)(content, vars);
|
|
2155
|
+
await (0, promises_1.writeFile)(destinationPath, renderedContent, 'utf8');
|
|
2156
|
+
}
|
|
2157
|
+
spinner.succeed(chalk.green(`Arquivos de localizacao criados com sucesso (${libraryLocalizationFiles.length + frontendLocalizationFiles.length}).`));
|
|
2158
|
+
spinner.succeed(chalk.green(`Library ${libraryName} created successfully at ${libraryPath}.`));
|
|
2159
|
+
}
|
|
2160
|
+
catch (error) {
|
|
2161
|
+
spinner.fail(chalk.red('Failed to create library.'));
|
|
2162
|
+
throw error;
|
|
2163
|
+
}
|
|
2164
|
+
finally {
|
|
2165
|
+
restoreWarnings();
|
|
2034
2166
|
}
|
|
2035
|
-
await (0, promises_1.mkdir)(pathModule.join(libraryPath, 'src'), { recursive: true });
|
|
2036
|
-
this.log(chalk.green(`Created directory: ${libraryPath}/src`));
|
|
2037
|
-
const vars = {
|
|
2038
|
-
path,
|
|
2039
|
-
libraryPath,
|
|
2040
|
-
libraryNamePascalCase: this.toPascalCase(libraryName),
|
|
2041
|
-
libraryNameSnackCase: this.toSnackCase(libraryName),
|
|
2042
|
-
libraryNameCamelCase: this.toCamelCase(libraryName),
|
|
2043
|
-
libraryNameKebabCase: this.toKebabCase(libraryName),
|
|
2044
|
-
libraryName: libraryName,
|
|
2045
|
-
};
|
|
2046
|
-
const files = [
|
|
2047
|
-
{
|
|
2048
|
-
template: '.eslintrc.js.ejs',
|
|
2049
|
-
destination: `/.eslintrc.js`,
|
|
2050
|
-
},
|
|
2051
|
-
{
|
|
2052
|
-
template: '.prettierrc.js.ejs',
|
|
2053
|
-
destination: `/.prettierrc.js`,
|
|
2054
|
-
},
|
|
2055
|
-
{
|
|
2056
|
-
template: 'package.json.ejs',
|
|
2057
|
-
destination: `/package.json`,
|
|
2058
|
-
},
|
|
2059
|
-
{
|
|
2060
|
-
template: 'tsconfig.json.ejs',
|
|
2061
|
-
destination: `/tsconfig.json`,
|
|
2062
|
-
},
|
|
2063
|
-
{
|
|
2064
|
-
template: 'tsconfig.production.json.ejs',
|
|
2065
|
-
destination: `/tsconfig.production.json`,
|
|
2066
|
-
},
|
|
2067
|
-
{
|
|
2068
|
-
template: 'module.ts.ejs',
|
|
2069
|
-
destination: `/src/${vars.libraryNameKebabCase}.module.ts`,
|
|
2070
|
-
},
|
|
2071
|
-
{
|
|
2072
|
-
template: 'index.ts.ejs',
|
|
2073
|
-
destination: `/src/index.ts`,
|
|
2074
|
-
},
|
|
2075
|
-
{
|
|
2076
|
-
template: 'en.json.ejs',
|
|
2077
|
-
destination: `/src/language/en.json`,
|
|
2078
|
-
},
|
|
2079
|
-
{
|
|
2080
|
-
template: 'pt.json.ejs',
|
|
2081
|
-
destination: `/src/language/pt.json`,
|
|
2082
|
-
},
|
|
2083
|
-
];
|
|
2084
|
-
for (const file of files) {
|
|
2085
|
-
const templatePath = pathModule.join(__dirname, '..', '..', 'templates', 'library', file.template);
|
|
2086
|
-
const destinationPath = pathModule.join(path, 'libraries', libraryName, file.destination);
|
|
2087
|
-
this.log(chalk.blue(`Rendering template: ${file.template}`));
|
|
2088
|
-
const content = await (0, promises_1.readFile)(templatePath, 'utf8');
|
|
2089
|
-
const renderedContent = await (0, ejs_1.render)(content, vars);
|
|
2090
|
-
await (0, promises_1.writeFile)(destinationPath, renderedContent, 'utf8');
|
|
2091
|
-
this.log(chalk.blue(`Created file: ${destinationPath}`));
|
|
2092
|
-
}
|
|
2093
|
-
this.log(chalk.green('Library files created successfully.'));
|
|
2094
|
-
await this.updateTsconfigFiles(path, verbose);
|
|
2095
|
-
if (!skipInstall) {
|
|
2096
|
-
this.log(chalk.blue(`Installing dependencies for ${libraryName}...`));
|
|
2097
|
-
await this.runner.executeCommand(runner_service_1.ProgramName.PNPM, ['install'], {
|
|
2098
|
-
cwd: libraryPath,
|
|
2099
|
-
}, true);
|
|
2100
|
-
this.log(chalk.green(`Dependencies installed for ${libraryName}.`));
|
|
2101
|
-
}
|
|
2102
|
-
const filesFrontend = [
|
|
2103
|
-
{
|
|
2104
|
-
template: 'page.tsx.ejs',
|
|
2105
|
-
destination: `/apps/admin/src/app/(app)/${vars.libraryNameKebabCase}/page.tsx`,
|
|
2106
|
-
},
|
|
2107
|
-
{
|
|
2108
|
-
template: 'en.json.ejs',
|
|
2109
|
-
destination: `/apps/admin/messages/${vars.libraryNameKebabCase}/en.json`,
|
|
2110
|
-
},
|
|
2111
|
-
{
|
|
2112
|
-
template: 'pt.json.ejs',
|
|
2113
|
-
destination: `/apps/admin/messages/${vars.libraryNameKebabCase}/pt.json`,
|
|
2114
|
-
},
|
|
2115
|
-
];
|
|
2116
|
-
for (const file of filesFrontend) {
|
|
2117
|
-
const templatePath = pathModule.join(__dirname, '..', '..', 'templates', 'library', file.template);
|
|
2118
|
-
const destinationPath = pathModule.join(path, file.destination);
|
|
2119
|
-
this.log(chalk.blue(`Rendering template: ${file.template}`));
|
|
2120
|
-
const content = await (0, promises_1.readFile)(templatePath, 'utf8');
|
|
2121
|
-
const renderedContent = await (0, ejs_1.render)(content, vars);
|
|
2122
|
-
await (0, promises_1.writeFile)(destinationPath, renderedContent, 'utf8');
|
|
2123
|
-
this.log(chalk.blue(`Created file: ${destinationPath}`));
|
|
2124
|
-
}
|
|
2125
|
-
this.log(chalk.green(`Library ${libraryName} created successfully at ${libraryPath}.`));
|
|
2126
2167
|
}
|
|
2127
2168
|
async hashDirectory(path) {
|
|
2128
2169
|
const sum = (0, crypto_1.createHash)('sha256');
|