diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 0514d85..73a1858 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,4 +1,3 @@ - name: CD on: @@ -6,7 +5,7 @@ on: types: [created] jobs: - build: + Build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -17,7 +16,7 @@ jobs: - run: npm run lint - run: npm run coverage - publish-npm: + Publish: needs: build runs-on: ubuntu-latest steps: diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index f3d2eeb..ff75c55 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -2,13 +2,12 @@ name: CI on: push: - branches: [ "main" ] + branches: ["main"] pull_request: - branches: [ "main" ] + branches: ["main"] jobs: - build: - + Build: runs-on: ubuntu-latest strategy: @@ -16,13 +15,13 @@ jobs: node-version: [16.x] steps: - - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - cache: 'npm' - - run: npm ci - - run: npm run lint - - run: npm run coverage - - run: npm run build + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: "npm" + - run: npm ci + - run: npm run lint + - run: npm run coverage + - run: npm run build diff --git a/README.md b/README.md index e121c95..6f11682 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ Below commands will install the `@latest` versions of the respective frameworks. | Svelte Kit | `npx twify@latest create svelte ` | | Laravel Vite | `npx twify@latest create laravel ` | | Vite | `npx twify@latest create vite ` | +| Solid Start | `npx twify@latest create solid ` | | Angular | `npx twify@latest create angular ` | | Create React App | `npx twify@latest create react ` | @@ -111,7 +112,7 @@ Below are the list of Supported Projects, | Vite | :white_check_mark: | :white_check_mark: | | Angular | :white_check_mark: | :white_check_mark: | | Create React App | :white_check_mark: | :white_check_mark: | -| Solid JS | :o: WIP | :o: WIP | +| Solid JS | :white_check_mark: | :white_check_mark: | | Astro | :o: WIP | :o: WIP | | Qwik | :o: WIP | :o: WIP | diff --git a/package-lock.json b/package-lock.json index f08f282..743cb7f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "twify", - "version": "0.4.3", + "version": "0.5.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "twify", - "version": "0.4.3", + "version": "0.5.0", "license": "MIT", "dependencies": { "chalk": "^5.0.1", diff --git a/package.json b/package.json index dd0e0a8..ee369cd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "twify", - "version": "0.4.3", + "version": "0.5.0", "description": "A Tool to Setup TailwindCSS in your Project with a Single Command", "bin": { "twify": "dist/main.js" diff --git a/src/drivers.ts b/src/drivers.ts index 644038b..349ff06 100644 --- a/src/drivers.ts +++ b/src/drivers.ts @@ -10,4 +10,5 @@ export const drivers = { Angular: (): DriverImport => import('./frameworks/angular'), CreateReactApp: (): DriverImport => import('./frameworks/cra'), LaravelVite: (): DriverImport => import('./frameworks/laravel'), + Solid: (): DriverImport => import('./frameworks/solid'), }; diff --git a/src/frameworks/solid.ts b/src/frameworks/solid.ts new file mode 100644 index 0000000..0cedb7e --- /dev/null +++ b/src/frameworks/solid.ts @@ -0,0 +1,12 @@ +import { Framework } from '../types'; +import { resolveCssLocation } from './steps/solid'; + +const Solid: Framework = { + requiredDependencies: ['tailwindcss', 'postcss', 'autoprefixer'], + initCommands: ['npx tailwindcss init -p'], + cssLocation: resolveCssLocation, + content: ['./src/**/*.{js,jsx,ts,tsx}'], + steps: [], +}; + +export default Solid; diff --git a/src/frameworks/steps/next.ts b/src/frameworks/steps/next.ts index 8e0d8b7..ad524f2 100644 --- a/src/frameworks/steps/next.ts +++ b/src/frameworks/steps/next.ts @@ -2,7 +2,9 @@ import glob from 'glob'; import util from 'util'; export async function resolveCssLocation() { - const [match] = await util.promisify(glob)('./**/globals.css'); + const [match] = await util.promisify(glob)('./**/globals.css', { + ignore: ['node_modules'], + }); if (!match) { return './styles/globals.css'; diff --git a/src/frameworks/steps/solid.ts b/src/frameworks/steps/solid.ts new file mode 100644 index 0000000..831f65d --- /dev/null +++ b/src/frameworks/steps/solid.ts @@ -0,0 +1,14 @@ +import glob from 'glob'; +import util from 'util'; + +export async function resolveCssLocation() { + const [match] = await util.promisify(glob)('./src/**/root.css', { + ignore: ['node_modules'], + }); + + if (!match) { + return './src/index.css'; + } + + return match; +} diff --git a/src/helpers.ts b/src/helpers.ts index 7a0e52a..995454a 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -39,6 +39,7 @@ export function detectFramework(): Driver | undefined { if (dependencies['nuxt']) return 'Nuxt2'; if (dependencies['@angular/core']) return 'Angular'; if (dependencies['react-scripts']) return 'CreateReactApp'; + if (dependencies['solid-js']) return 'Solid'; if (devDependencies['laravel-vite-plugin']) return 'LaravelVite'; if (devDependencies['@sveltejs/kit']) return 'SvelteKit'; if (devDependencies['nuxt']) return 'Nuxt3'; diff --git a/src/makers.ts b/src/makers.ts index ed8771c..ead7ade 100644 --- a/src/makers.ts +++ b/src/makers.ts @@ -1,8 +1,7 @@ import { runCommand } from './helpers'; -import { PackageManager } from './types'; -import { drivers } from './drivers'; +import { Driver, PackageManager } from './types'; -export type Maker = { cmd: string; project: keyof typeof drivers }; +export type Maker = { cmd: string; project: Driver }; export type SpecialMaker = (packageManager: PackageManager) => Promise; const globalInstallPrefix: Record = { @@ -38,6 +37,7 @@ const regularMakes: Record = { next: { cmd: 'next-app', project: 'NextJS' }, react: { cmd: 'react-app', project: 'CreateReactApp' }, nuxt: { cmd: 'nuxt-app', project: 'Nuxt2' }, + solid: { cmd: 'solid', project: 'Solid' }, }; export async function resolveMakeCommand(args: string[]): Promise { diff --git a/tests/__snapshots__/drivers.spec.ts.snap b/tests/__snapshots__/drivers.spec.ts.snap index 0e9f747..12bd8b0 100644 --- a/tests/__snapshots__/drivers.spec.ts.snap +++ b/tests/__snapshots__/drivers.spec.ts.snap @@ -189,3 +189,21 @@ exports[`Drivers > has a list of drivers 9`] = ` ], } `; + +exports[`Drivers > has a list of drivers 10`] = ` +{ + "content": [ + "./src/**/*.{js,jsx,ts,tsx}", + ], + "cssLocation": [Function], + "initCommands": [ + "npx tailwindcss init -p", + ], + "requiredDependencies": [ + "tailwindcss", + "postcss", + "autoprefixer", + ], + "steps": [], +} +`; diff --git a/tests/drivers.spec.ts b/tests/drivers.spec.ts index e166d7c..1062701 100644 --- a/tests/drivers.spec.ts +++ b/tests/drivers.spec.ts @@ -13,6 +13,7 @@ describe('Drivers', () => { 'Angular', 'CreateReactApp', 'LaravelVite', + 'Solid', ] as (keyof typeof drivers)[]; expect(driversList).toEqual(expectedDrivers); diff --git a/tests/helpers.spec.ts b/tests/helpers.spec.ts index 430b893..60b9127 100644 --- a/tests/helpers.spec.ts +++ b/tests/helpers.spec.ts @@ -47,6 +47,9 @@ describe('Helpers', () => { pkg.mockReturnValue({ dependencies: { 'react-scripts': '1.0.0' } }); expect(detectFramework()).toBe('CreateReactApp'); + pkg.mockReturnValue({ dependencies: { 'solid-js': '1.0.0' } }); + expect(detectFramework()).toBe('Solid'); + pkg.mockReturnValue({ devDependencies: { 'laravel-vite-plugin': '1.0.0' }, }); diff --git a/tests/steps/next.spec.ts b/tests/steps/next.spec.ts index d227c83..5ccd3b9 100644 --- a/tests/steps/next.spec.ts +++ b/tests/steps/next.spec.ts @@ -14,14 +14,14 @@ describe('Next JS CSS', () => { it('can resolve css location', async () => { vi.mocked(glob) - .mockImplementationOnce((_, cb) => { + .mockImplementationOnce((_, __, cb) => { console.log(typeof cb, cb); // eslint-disable-next-line @typescript-eslint/no-explicit-any - return (cb as any)(null, ['foo']) as any; + return cb(null, ['foo']) as any; }) - .mockImplementationOnce((_, cb) => { + .mockImplementationOnce((_, __, cb) => { // eslint-disable-next-line @typescript-eslint/no-explicit-any - return (cb as any)(null, []) as any; + return cb(null, []) as any; }); const first = await resolveCssLocation(); const second = await resolveCssLocation(); diff --git a/tests/steps/solid.spec.ts b/tests/steps/solid.spec.ts new file mode 100644 index 0000000..4822bcb --- /dev/null +++ b/tests/steps/solid.spec.ts @@ -0,0 +1,32 @@ +import glob from 'glob'; +import { resolveCssLocation } from '../../src/frameworks/steps/solid'; + +vi.mock('glob'); + +describe('Solid JS CSS', () => { + afterEach(() => { + vi.clearAllMocks(); + }); + + afterAll(() => { + vi.resetAllMocks(); + }); + + it('can resolve css location', async () => { + vi.mocked(glob) + .mockImplementationOnce((_, __, cb) => { + console.log(typeof cb, cb); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return cb(null, ['foo']) as any; + }) + .mockImplementationOnce((_, __, cb) => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return cb(null, []) as any; + }); + const first = await resolveCssLocation(); + const second = await resolveCssLocation(); + + expect(first).toStrictEqual('foo'); + expect(second).toStrictEqual('./src/index.css'); + }); +});