Skip to content

Commit

Permalink
0.1.0
Browse files Browse the repository at this point in the history
First beta release
  • Loading branch information
hyochan committed Jun 26, 2023
1 parent ea3211f commit 202dcf5
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 27 deletions.
13 changes: 5 additions & 8 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# bin/root.js.map
# bin/root.ts
# utils/functions.js.map
# utils/functions.ts

utils/functions.ts
bin/root.ts
package/
**/*
!lib/**/*
!LICENSE.md
!package.json
!README.md
4 changes: 1 addition & 3 deletions bin/cb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ export const cbResultExpo = (
shell.echo(chalk.greenBright(`Created ${nameOfApp} successfully.`));

shell.echo(
chalk.greenBright(
`cd ${nameOfApp} and yarn && yarn start. Open up another terminal and yarn run ios.`,
),
chalk.greenBright(`Run cd ${nameOfApp} and yarn && yarn start.`),
);

spinner.stop();
Expand Down
31 changes: 25 additions & 6 deletions bin/root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ program
process.exit(0);
}

const spinner = ora('creating app ' + nameOfApp + '...\n');
const spinner = ora('Creating app ' + nameOfApp + '...\n');

spinner.start();

Expand Down Expand Up @@ -318,17 +318,18 @@ program

if (exists) {
const template = resolveTemplate({
componentName: upperCamel,
projectType: 'expo',
componentType,
});

shell.echo(
chalk.cyanBright('Creating page component in app directory...'),
);

shell.cp(template.file, component.file);
shell.cp(template.testFile, component.testFile);
shell.sed('-i', 'Page', `${upperCamel}`, component.testFile);

shell.sed(
'-i',
`../../${componentType}/Page`,
Expand Down Expand Up @@ -375,10 +376,28 @@ program
process.exit(0);
}

const template = resolveTemplate({
componentType,
projectType: 'expo',
});

shell.echo(chalk.cyanBright('Creating template component...'));
shell.cp(template.file, component.file);
shell.cp(template.testFile, component.testFile);

shell.sed('-i', 'Component', `${upperCamel}`, component.file);
shell.sed(
'-i',
'../../../src/uis/UI',
`../../../src/uis/${upperCamel}`,
component.testFile,
);

shell.echo(
chalk.redBright(
`\nProject is not in dooboo repository.
If you deleted any of file in .dooboo, you are not able to use dooboo-cli.`,
chalk.green(
`Generated:${'\n'}File: ${component.file}${'\n'}testFile: ${
component.testFile
}`,
),
);

Expand Down Expand Up @@ -438,7 +457,7 @@ program
const upperCamel = toPascalCase(c);

const providerFile = `./src/${componentType}/${upperCamel}.tsx`;
const providerTestFile = `./test/${componentType}/${upperCamel}.test.tsx`;
const providerTestFile = `./test/src/${componentType}/${upperCamel}.test.tsx`;
const exists = fs.existsSync(providerFile);

if (exists) {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dooboo",
"version": "0.0.3",
"version": "0.1.0",
"description": "Expo and expo router starter kit maintained by dooboolab.",
"bin": {
"dooboo": "lib/bin/root.js"
Expand Down
15 changes: 8 additions & 7 deletions utils/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,25 @@ export type ProjectType = 'expo';
export const resolveTemplate = ({
projectType,
componentType,
componentName,
fileExt = 'tsx',
}: {
projectType: ProjectType;
componentType: ComponentType;
componentName: string;
fileExt?: string;
}): TemplateFileType => {
const filePrefix =
componentType === 'uis' ? 'UI' : componentType === 'app' ? 'Page' : '';

const template = path.resolve(
__dirname,
'..',
`templates/${projectType}/${componentType}/${componentName}.${fileExt}`,
`templates/${projectType}/${componentType}/${filePrefix}.${fileExt}`,
);

const testTemplate = path.resolve(
__dirname,
'..',
`templates/${projectType}/${componentType}/${componentName}.test.${fileExt}`,
`templates/${projectType}/${componentType}/${filePrefix}.test.${fileExt}`,
);

return {
Expand Down Expand Up @@ -104,8 +105,8 @@ export const toPascalCase = (str: string): string => {

export function pascalToKebabCase(str: string): string {
return str
.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2') // split before uppercase letters
.toLowerCase(); // convert to lower case
.replace(/\.?([A-Z]+)/g, (x, y) => '-' + y.toLowerCase())
.replace(/^-/, '');
}

export const exec = (command: string): Promise<string> => {
Expand Down Expand Up @@ -143,7 +144,7 @@ export const resolveComponent = ({
}

const component = `./src/${type}/${name}.${fileExt}`;
const testComponent = `./test/${type}/${name}.test.${fileExt}`;
const testComponent = `./test/src/${type}/${name}.test.${fileExt}`;

return {
file: component,
Expand Down

0 comments on commit 202dcf5

Please sign in to comment.