Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ Build for production:
npm run build
```

Non-interactive setup (for automation):

```bash
npm run init -- --script ts --style scss --markup pug --normalize --reset --yes
```

Quality checks:

```bash
Expand Down Expand Up @@ -81,6 +87,7 @@ This repository now includes:
- Unit tests for filesystem utilities (`npm test`)
- CI workflow for typecheck + tests (GitHub Actions)
- Contributing and security documentation
- A single runtime architecture: setup always generates one `gulpfile.js` from user choices (no parallel dynamic task runtime)

---

Expand Down
110 changes: 0 additions & 110 deletions _gulp/combineTasks.ts

This file was deleted.

13 changes: 9 additions & 4 deletions _gulp/gulpSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@ import { writeFile } from 'fs/promises';
import { copyVendorCSS, createProjectFiles, createProjectStructure } from './modules/fileSetup';
import { generateGulpfile } from './modules/gulpfileGenerator';
import { confirmProjectDeletion, promptUser } from './modules/setupQuestions';
import { parseSetupOptions } from './modules/setupCliOptions';
import { assertUserChoices } from './modules/userChoicesValidation';
import { UserChoices } from './types';
import { deleteDirectory, fileExists } from './utils/fileSystem';
import { logger } from './utils/logger';

async function setup(): Promise<void> {
try {
const parsedOptions = parseSetupOptions(process.argv.slice(2));

const projectExists = fileExists('src') || fileExists('dist');
if (projectExists) {
const shouldDelete = await confirmProjectDeletion();
const shouldDelete = parsedOptions.autoConfirm ? true : await confirmProjectDeletion();
if (!shouldDelete) {
logger.info('Project setup canceled. Exiting...');
return;
Expand All @@ -20,8 +24,9 @@ async function setup(): Promise<void> {
deleteDirectory('dist');
}

const choices: UserChoices = await promptUser();

const rawChoices = parsedOptions.shouldPrompt ? await promptUser() : parsedOptions.choices;
const choices: UserChoices = assertUserChoices(rawChoices);

await writeFile('_gulp/user-choices.json', JSON.stringify(choices, null, 2));

createProjectStructure(choices);
Expand All @@ -32,7 +37,7 @@ async function setup(): Promise<void> {
logger.success('Setup complete. Gulpfile has been generated.');
logger.info('Starting development server...');

exec('yarn start', (error, stdout, stderr) => {
exec('npm start', (error, stdout, stderr) => {
if (error) {
logger.error(`Error: ${error.message}`);
return;
Expand Down
40 changes: 0 additions & 40 deletions _gulp/modules/buildEnvironment.ts

This file was deleted.

28 changes: 15 additions & 13 deletions _gulp/modules/fileSetup.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { resolveProjectPaths } from './pathConfig';
import { UserChoices } from '../types';
import { copyFile, createDirectory, writeFile } from '../utils/fileSystem';

export function createProjectStructure(choices: UserChoices): void {
const paths = resolveProjectPaths(choices);

const dirs = [
'src',
`src/${choices.script === 'JavaScript' ? 'js' : 'ts'}`,
`src/${choices.style === 'Sass' ? 'sass/base' : 'scss/base'}`, // Updated path for base
`src/${choices.markup === 'HTML' ? 'html' : 'pug'}`,
`src/${paths.scriptFolder}`,
`src/${paths.styleBaseFolder}`,
`src/${paths.markupFolder}`,
'src/img',
'dist/css'
];
Expand All @@ -15,35 +18,34 @@ export function createProjectStructure(choices: UserChoices): void {
}

export function createProjectFiles(choices: UserChoices): void {
const scriptExt = choices.script === 'JavaScript' ? 'js' : 'ts';
const styleExt = choices.style === 'Sass' ? 'sass' : 'scss';
const paths = resolveProjectPaths(choices);

const scriptContent = choices.script === 'JavaScript'
? 'console.log("Hello, World!");'
: 'console.log("Hello, TypeScript!");';
writeFile(`src/${scriptExt}/main.${scriptExt}`, scriptContent);
writeFile(`src/${paths.scriptFolder}/main.${paths.scriptExtension}`, scriptContent);

let styleContent = `// Main ${choices.style} file\n`;
if (choices.addNormalize) styleContent += choices.style === 'Sass' ? "@import 'base/normalize'\n" : "@import 'base/normalize';\n";
if (choices.addReset) styleContent += choices.style === 'Sass' ? "@import 'base/reset'\n" : "@import 'base/reset';\n";
writeFile(`src/${styleExt}/main.${styleExt}`, styleContent);
writeFile(`src/${paths.styleFolder}/main.${paths.styleExtension}`, styleContent);

const markupContent = choices.markup === 'HTML' ? getHtmlTemplate() : getPugTemplate();
const markupFilePath = choices.markup === 'HTML' ? 'src/html/index.html' : 'src/pug/index.pug';

writeFile(markupFilePath, markupContent);
writeFile(`src/${paths.markupFolder}/index.${paths.markupExtension}`, markupContent);
writeFile('src/favicon.ico', '');
}

export function copyVendorCSS(choices: UserChoices): void {
const paths = resolveProjectPaths(choices);

const vendorFiles = [
{ type: 'Normalize', src: `_gulp/vendors/normalize.${choices.style === 'Sass' ? 'sass' : 'scss'}` },
{ type: 'Reset', src: `_gulp/vendors/reset.${choices.style === 'Sass' ? 'sass' : 'scss'}` }
{ type: 'Normalize', src: `_gulp/vendors/normalize.${paths.styleExtension}` },
{ type: 'Reset', src: `_gulp/vendors/reset.${paths.styleExtension}` }
];

vendorFiles.forEach(file => {
if (choices[`add${file.type}` as keyof UserChoices]) {
const dest = `src/${choices.style === 'Sass' ? 'sass/base' : 'scss/base'}/_${file.type.toLowerCase()}.${choices.style === 'Sass' ? 'sass' : 'scss'}`; // Save in base folder
const dest = `src/${paths.styleBaseFolder}/_${file.type.toLowerCase()}.${paths.styleExtension}`;
copyFile(file.src, dest);
}
});
Expand Down
Loading
Loading