Skip to content

Commit

Permalink
fix: new file structure
Browse files Browse the repository at this point in the history
  • Loading branch information
luangjokaj committed Mar 30, 2024
1 parent ff73dea commit fe55694
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 78 deletions.
191 changes: 119 additions & 72 deletions installer/modules/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,30 +40,42 @@ const run = () => {
`${upstreamUrl}/installer/package.json`,
`${upstreamUrl}/installer/package-lock.json`,

`${upstreamUrl}/src/assets/css/parts/footer.css`,
`${upstreamUrl}/src/assets/css/parts/header.css`,

`${upstreamUrl}/src/assets/css/patterns/sample.css`,

`${upstreamUrl}/src/assets/css/style.css`,
`${upstreamUrl}/src/assets/css/wordpressify.css`,

`${upstreamUrl}/src/assets/js/main.js`,
`${upstreamUrl}/src/assets/fonts/inter/Inter-VariableFont_slnt,wght.woff2`,
`${upstreamUrl}/src/assets/fonts/inter/LICENSE.txt`,

`${upstreamUrl}/src/assets/img/logo.svg`,

`${upstreamUrl}/src/theme/404.php`,
`${upstreamUrl}/src/theme/archive.php`,
`${upstreamUrl}/src/theme/comments.php`,
`${upstreamUrl}/src/theme/content-none.php`,
`${upstreamUrl}/src/theme/content-page.php`,
`${upstreamUrl}/src/theme/content-single.php`,
`${upstreamUrl}/src/theme/content.php`,
`${upstreamUrl}/src/theme/footer.php`,
`${upstreamUrl}/src/assets/js/main.js`,

`${upstreamUrl}/src/theme/parts/footer.html`,
`${upstreamUrl}/src/theme/parts/header.html`,

`${upstreamUrl}/src/theme/patterns/footer.php`,
`${upstreamUrl}/src/theme/patterns/header.php`,
`${upstreamUrl}/src/theme/patterns/sample.php`,

`${upstreamUrl}/src/theme/templates/404.html`,
`${upstreamUrl}/src/theme/templates/archive.html`,
`${upstreamUrl}/src/theme/templates/blank.html`,
`${upstreamUrl}/src/theme/templates/home.html`,
`${upstreamUrl}/src/theme/templates/index.html`,
`${upstreamUrl}/src/theme/templates/page-no-title-full-width.html`,
`${upstreamUrl}/src/theme/templates/page-no-title.html`,
`${upstreamUrl}/src/theme/templates/page.html`,
`${upstreamUrl}/src/theme/templates/search.html`,
`${upstreamUrl}/src/theme/templates/single.html`,

`${upstreamUrl}/src/theme/functions.php`,
`${upstreamUrl}/src/theme/header.php`,
`${upstreamUrl}/src/theme/index.php`,
`${upstreamUrl}/src/theme/page.php`,
`${upstreamUrl}/src/theme/screenshot.png`,
`${upstreamUrl}/src/theme/search.php`,
`${upstreamUrl}/src/theme/searchform.php`,
`${upstreamUrl}/src/theme/sidebar.php`,
`${upstreamUrl}/src/theme/single.php`,
`${upstreamUrl}/src/theme/theme.json`,

`${upstreamUrl}/config/php.ini`,
`${upstreamUrl}/config/nginx/nginx.conf`,
Expand All @@ -79,111 +91,146 @@ const run = () => {
'.stylelintrc',
];
const cssFiles = ['style.css', 'wordpressify.css'];
const jsFiles = ['main.js'];
const cssPartsFiles = ['footer.css', 'header.css'];
const cssPatternsFiles = ['sample.css'];
const fontFiles = ['Inter-VariableFont_slnt,wght.woff2', 'LICENSE.txt'];
const imgFiles = ['logo.svg'];
const themeFiles = [
'404.php',
'archive.php',
'comments.php',
'content-none.php',
'content-page.php',
'content-single.php',
'content.php',
'footer.php',
'functions.php',
'header.php',
'index.php',
'page.php',
'screenshot.png',
'search.php',
'searchform.php',
'sidebar.php',
'single.php',
const jsFiles = ['main.js'];
const themeFiles = ['functions.php', 'screenshot.png', 'theme.json'];
const partsFiles = ['footer.html', 'header.html'];
const patternsFiles = ['footer.php', 'header.php', 'sample.php'];
const templatesFiles = [
'404.html',
'archive.html',
'blank.html',
'home.html',
'index.html',
'page-no-title-full-width.html',
'page-no-title.html',
'page.html',
'search.html',
'single.html',
];

const configFiles = ['php.ini'];
const nginxFiles = [
'nginx.conf',
];
const nginxFiles = ['nginx.conf'];

// Start
console.log('\n');
console.log(
'📦 ',
chalk.black.bgYellow(
` Downloading 🎈 WordPressify files in: → ${chalk.bgGreen(
` ${theDir} `
)}\n`
` Downloading 🎈 WordPressify files in: → ${chalk.bgGreen(` ${theDir} `)}\n`,
),
chalk.dim(`\n In the directory: ${theCWD}\n`),
chalk.dim('This might take a couple of minutes.\n')
chalk.dim('This might take a couple of minutes.\n'),
);

const spinner = ora({ text: '' });
spinner.start(
`1. Creating 🎈 WordPressify files inside → ${chalk.black.bgWhite(
` ${theDir} `
)}`
` ${theDir} `,
)}`,
);

// Download
Promise.all(filesToDownload.map((x) => download(x, `${theCWD}`))).then(
async () => {
if (!fs.existsSync('src')) {
await execa('mkdir', [
'config',
'config/nginx',
'src',
'src/theme',
'src/plugins',
'src/assets',
'src/assets/css',
'src/assets/js',
'src/assets/css/parts',
'src/assets/css/patterns',
'src/assets/fonts',
'src/assets/fonts/inter',
'src/assets/img',
'config',
'config/nginx',
'src/assets/js',
'src/plugins',
'src/theme',
'src/theme/parts',
'src/theme/patterns',
'src/theme/templates',
]);
}

dotFiles.map((x) =>
fs.renameSync(`${theCWD}/${x.slice(1)}`, `${theCWD}/${x}`, (err) =>
handleError(err)
)
handleError(err),
),
);
cssFiles.map((x) =>
fs.renameSync(`${theCWD}/${x}`, `${theCWD}/src/assets/css/${x}`, (err) =>
handleError(err),
),
);
cssPartsFiles.map((x) =>
fs.renameSync(
`${theCWD}/${x}`,
`${theCWD}/src/assets/css/${x}`,
(err) => handleError(err)
)
`${theCWD}/src/assets/css/parts/${x}`,
(err) => handleError(err),
),
);
jsFiles.map((x) =>
cssPatternsFiles.map((x) =>
fs.renameSync(
`${theCWD}/${x}`,
`${theCWD}/src/assets/js/${x}`,
(err) => handleError(err)
)
`${theCWD}/src/assets/css/patterns/${x}`,
(err) => handleError(err),
),
);
imgFiles.map((x) =>
fontFiles.map((x) =>
fs.renameSync(
`${theCWD}/${x}`,
`${theCWD}/src/assets/img/${x}`,
(err) => handleError(err)
)
`${theCWD}/src/assets/fonts/inter/${x}`,
(err) => handleError(err),
),
);
imgFiles.map((x) =>
fs.renameSync(`${theCWD}/${x}`, `${theCWD}/src/assets/img/${x}`, (err) =>
handleError(err),
),
);
jsFiles.map((x) =>
fs.renameSync(`${theCWD}/${x}`, `${theCWD}/src/assets/js/${x}`, (err) =>
handleError(err),
),
);
themeFiles.map((x) =>
fs.renameSync(`${theCWD}/${x}`, `${theCWD}/src/theme/${x}`, (err) =>
handleError(err)
)
handleError(err),
),
);
partsFiles.map((x) =>
fs.renameSync(`${theCWD}/${x}`, `${theCWD}/src/theme/parts/${x}`, (err) =>
handleError(err),
),
);
patternsFiles.map((x) =>
fs.renameSync(
`${theCWD}/${x}`,
`${theCWD}/src/theme/patterns/${x}`,
(err) => handleError(err),
),
);
templatesFiles.map((x) =>
fs.renameSync(
`${theCWD}/${x}`,
`${theCWD}/src/theme/templates/${x}`,
(err) => handleError(err),
),
);
configFiles.map((x) =>
fs.renameSync(`${theCWD}/${x}`, `${theCWD}/config/${x}`, (err) =>
handleError(err)
)
handleError(err),
),
);
nginxFiles.map((x) =>
fs.renameSync(
`${theCWD}/${x}`,
`${theCWD}/config/nginx/${x}`,
(err) => handleError(err)
)
fs.renameSync(`${theCWD}/${x}`, `${theCWD}/config/nginx/${x}`, (err) =>
handleError(err),
),
);
spinner.succeed();

Expand All @@ -192,7 +239,7 @@ const run = () => {

// Done
printNextSteps();
}
},
);
};

Expand Down
4 changes: 2 additions & 2 deletions installer/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 installer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wordpressify",
"version": "0.4.0-10",
"version": "0.5.0",
"description": "Automate your WordPress development workflow.",
"keywords": [
"babel",
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": "wordpressify",
"version": "0.5.0",
"version": "0.5.0-1",
"description": "Automate your WordPress development workflow.",
"keywords": [
"babel",
Expand Down

0 comments on commit fe55694

Please sign in to comment.