Skip to content
This repository has been archived by the owner on Jan 1, 2025. It is now read-only.

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed Oct 6, 2022
1 parent b5e3c54 commit a70cd79
Show file tree
Hide file tree
Showing 69 changed files with 1,530 additions and 7,736 deletions.
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.9.0
18.10.0
5 changes: 4 additions & 1 deletion .stacks/.eslintrc-auto-import.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"asyncComputed": true,
"author": true,
"autoResetRef": true,
"bcrypt": true,
"beforeAll": true,
"beforeEach": true,
"chai": true,
Expand Down Expand Up @@ -39,10 +40,12 @@
"defineComponent": true,
"describe": true,
"docs": true,
"driver": true,
"eagerComputed": true,
"effectScope": true,
"expect": true,
"extendRef": true,
"functions": true,
"functionsLibrary": true,
"getCurrentInstance": true,
"getCurrentScope": true,
Expand Down Expand Up @@ -99,7 +102,7 @@
"refThrottled": true,
"refWithControl": true,
"repository": true,
"resetPreset": true,
"reset": true,
"resolveComponent": true,
"resolveRef": true,
"resolveUnref": true,
Expand Down
1 change: 1 addition & 0 deletions .stacks/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.nitro
.output
src/components/.vite-inspect
core/build/entries/*.ts
4 changes: 2 additions & 2 deletions .stacks/artisan/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "artisan-init",
"type": "module",
"version": "0.33.5",
"packageManager": "pnpm@7.12.2",
"version": "0.33.7",
"packageManager": "pnpm@7.13.0",
"description": "Artisan core.",
"author": "Chris Breuer",
"license": "MIT",
Expand Down
29 changes: 29 additions & 0 deletions .stacks/artisan/src/cli/generate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import type { CAC } from 'cac'
import { generateLibEntry } from '../../../core'
import { generateTypes } from '../scripts/generate'

async function generateCommands(artisan: CAC) {
artisan
.command('generate:types', 'Generates the types of & for your library/libraries')
.action(async () => {
await generateTypes()
})

artisan
.command('generate:entries', 'Generates the entry points for your libraries')
.action(async () => {
await generateLibEntry('vue-components')
await generateLibEntry('web-components')
await generateLibEntry('functions')
})

artisan
.command('generate:vue-compatibility', 'Generates Vue 2 & 3 compatibility')
.action(async () => {
// eslint-disable-next-line no-console
console.log('wip')
// await generateVueCompat()
})
}

export { generateCommands }
3 changes: 2 additions & 1 deletion .stacks/artisan/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ import { exampleCommands } from './example'
import { testCommands } from './test'
import { initCommands } from './init'
import { updateCommands } from './update'
import { generateCommands } from './generate'

export { devCommands, buildCommands, utilityCommands, makeCommands, exampleCommands, testCommands, initCommands, updateCommands }
export { devCommands, buildCommands, utilityCommands, makeCommands, exampleCommands, testCommands, initCommands, updateCommands, generateCommands }
2 changes: 1 addition & 1 deletion .stacks/artisan/src/cli/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { resolve } from 'pathe'
import { bold, cyan, dim } from 'kolorist'
import { useOnline } from '@vueuse/core'
import { version } from '../../package.json'
import { isFolder } from '../../../src/core/fs'
import { isFolder } from '../../../core'
import { generate as generateAppKey } from '../scripts/key'
import { ExitCode } from './exit-code'

Expand Down
7 changes: 0 additions & 7 deletions .stacks/artisan/src/cli/utility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { reinstallNpmDependencies } from '../scripts/fresh'
import { lint, lintFix } from '../scripts/lint'
import { release } from '../scripts/release'
import { commit } from '../scripts/commit'
import { generateTypes } from '../scripts/generate'

async function utilityCommands(artisan: CAC) {
artisan
Expand Down Expand Up @@ -35,12 +34,6 @@ async function utilityCommands(artisan: CAC) {
.action(async () => {
await commit()
})

artisan
.command('generate:types', 'Generates the types of your library/libraries.')
.action(async () => {
await generateTypes()
})
}

export { utilityCommands }
5 changes: 3 additions & 2 deletions .stacks/artisan/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env node
import cac from 'cac'
import { isInitialized } from '../../src/core/helpers'
import { isInitialized } from '../../core'
import { version } from '../../../package.json'
import { buildCommands, devCommands, exampleCommands, initCommands, makeCommands, testCommands, updateCommands, utilityCommands } from './cli'
import { buildCommands, devCommands, exampleCommands, generateCommands, initCommands, makeCommands, testCommands, updateCommands, utilityCommands } from './cli'
import { ExitCode } from './cli/exit-code'
import { generate as generateAppKey } from './scripts/key'

Expand All @@ -26,6 +26,7 @@ async function main() {
}
else {
await updateCommands(artisan)
await generateCommands(artisan)
await devCommands(artisan)
await buildCommands(artisan)
await utilityCommands(artisan)
Expand Down
11 changes: 6 additions & 5 deletions .stacks/artisan/src/scripts/build.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import { resolve } from 'pathe'
import Prompts from 'prompts'
import consola from 'consola'
import { NpmScript } from '../../../src/types'
import { hasFiles } from '../../../src/core/fs'
import { NpmScript, generateLibEntry, hasFiles } from '../../../core'
import { ExitCode } from '../cli/exit-code'
import { runNpmScript } from './run-npm-script'
import { generateTypes } from './generate'

const { prompts } = Prompts

export async function buildComponentLibraries() {
await generateLibEntry('vue-components')
await generateLibEntry('web-components')
await buildVueComponentLibrary()
await buildWebComponentLibrary()
}

export async function buildVueComponentLibrary() {
consola.info('Building your component library for production use & npm/CDN distribution...')
consola.info('Building your component library...')

if (hasFiles(resolve(process.cwd(), './components'))) {
try {
Expand All @@ -38,10 +39,10 @@ export async function buildWebComponentLibrary() {
if (hasFiles(resolve(process.cwd(), './components'))) {
try {
await runNpmScript(NpmScript.BuildWebComponents)
consola.success('Your web component library was built successfully.')
consola.success('Your Web Component library was built successfully.')
}
catch (error) {
consola.error('There was an error building your web component library.')
consola.error('There was an error building your Web Component library.')
consola.error(error)
}
}
Expand Down
2 changes: 1 addition & 1 deletion .stacks/artisan/src/scripts/commit.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import consola from 'consola'
import { NpmScript } from '../../../src/types'
import { NpmScript } from '../../../core'
import { runNpmScript } from './run-npm-script'

export async function commit() {
Expand Down
2 changes: 1 addition & 1 deletion .stacks/artisan/src/scripts/dev.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Prompts from 'prompts'
import consola from 'consola'
import { NpmScript } from '../../../src/types'
import { NpmScript } from '../../../core'
import { ExitCode } from '../cli/exit-code'
import { runNpmScript } from './run-npm-script'

Expand Down
9 changes: 4 additions & 5 deletions .stacks/artisan/src/scripts/examples.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { resolve } from 'pathe'
import Prompts from 'prompts'
import consola from 'consola'
import { NpmScript } from '../../../src/types'
import { hasFiles } from '../../../src/core/fs'
import { NpmScript, hasFiles } from '../../../core'
import { ExitCode } from '../cli/exit-code'
import { runNpmScript } from './run-npm-script'

Expand All @@ -25,15 +24,15 @@ export async function testComponentExample() {
}

export async function testWebComponentExample() {
consola.info('Building your web component library for production use & npm/CDN distribution...')
consola.info('Building your Web Component library...')

if (hasFiles(resolve(process.cwd(), './components'))) {
try {
await runNpmScript(NpmScript.BuildWebComponents)
consola.success('Your web component library was built successfully.')
consola.success('Your Web Component library was built successfully.')
}
catch (error) {
consola.error('There was an error building your web component library.')
consola.error('There was an error building your Web Component library.')
consola.error(error)
}
}
Expand Down
2 changes: 1 addition & 1 deletion .stacks/artisan/src/scripts/fresh.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import consola from 'consola'
import { NpmScript } from '../../../src/types'
import { NpmScript } from '../../../core'
import { runNpmScript } from './run-npm-script'

export async function reinstallNpmDependencies() {
Expand Down
34 changes: 29 additions & 5 deletions .stacks/artisan/src/scripts/generate.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,36 @@
import consola from 'consola'
import { NpmScript } from '../../../src/types'
import { NpmScript } from '../../../core'
import { runNpmScript } from './run-npm-script'

export async function generateTypes() {
await runNpmScript(NpmScript.GenerateTypes).then(() => {
try {
await runNpmScript(NpmScript.GenerateTypes)
consola.success('Types were generated successfully.')
}).catch((error) => {
consola.error('There was an error generating your types')
}
catch (error) {
consola.error('There was an error generating your types.')
consola.error(error)
})
}
}

export async function generateLibEntries() {
try {
await runNpmScript(NpmScript.generateEntries)
consola.success('Library entry points were generated successfully.')
}
catch (error) {
consola.error('There was an error generating your library entry points.')
consola.error(error)
}
}

export async function generateVueCompat() {
try {
await runNpmScript(NpmScript.generateVueCompat)
consola.success('Vue 2 & 3 compatibility was generated successfully.')
}
catch (error) {
consola.error('There was an error generating Vue compatibility.')
consola.error(error)
}
}
10 changes: 8 additions & 2 deletions .stacks/artisan/src/scripts/key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@ import fs from 'fs-extra'
import consola from 'consola'
import { enc } from 'crypto-js'
import { resolve } from 'pathe'
import ezSpawn from '@jsdevtools/ez-spawn'
import { isFile } from '../../../core/utils'

export async function generate(path: string) {
consola.info('Generating random application key.')
consola.info('Setting random application key.')

// if the .env file does not exist, ensure it is created
if (!isFile('.env'))
await ezSpawn.async('cp .env.example .env', { stdio: 'inherit' })

const random = crypto.getRandomValues(new Uint8Array(32))
const encodedWord = enc.Utf8.parse(random.toString())
Expand All @@ -14,7 +20,7 @@ export async function generate(path: string) {

await setEnvValue('APP_KEY', APP_KEY, path)

consola.success('Generated key.')
consola.success('Application key set.')
}

async function setEnvValue(key: string, value: string, path?: string) {
Expand Down
2 changes: 1 addition & 1 deletion .stacks/artisan/src/scripts/lint.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import consola from 'consola'
import { NpmScript } from '../../../src/types'
import { NpmScript } from '../../../core'
import { runNpmScript } from './run-npm-script'

export async function lint() {
Expand Down
2 changes: 1 addition & 1 deletion .stacks/artisan/src/scripts/make.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { resolve } from 'pathe'
import consola from 'consola'
import * as ezSpawn from '@jsdevtools/ez-spawn'
import { writeTextFile } from '../../../src/core/fs'
import { writeTextFile } from '../../../core'

export async function component(name: string) {
consola.info('Creating your component...')
Expand Down
2 changes: 1 addition & 1 deletion .stacks/artisan/src/scripts/release.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import consola from 'consola'
import { NpmScript } from '../../../src/types'
import { NpmScript } from '../../../core'
import { runNpmScript } from './run-npm-script'

export async function release() {
Expand Down
5 changes: 2 additions & 3 deletions .stacks/artisan/src/scripts/run-npm-script.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { resolve } from 'pathe'
import * as ezSpawn from '@jsdevtools/ez-spawn'
import consola from 'consola'
import { readJsonFile } from '../../../src/core/fs'
import type { Manifest, NpmScript } from '../../../src/types'
import { isManifest } from '../../../src/core/manifest'
import { isManifest, readJsonFile } from '../../../core'
import type { Manifest, NpmScript } from '../../../core'

/**
* Runs the specified NPM script in the package.json file.
Expand Down
2 changes: 1 addition & 1 deletion .stacks/artisan/src/scripts/test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import consola from 'consola'
import { NpmScript } from '../../../src/types'
import { NpmScript } from '../../../core'
import { runNpmScript } from './run-npm-script'

export async function typecheck() {
Expand Down
3 changes: 1 addition & 2 deletions .stacks/artisan/src/scripts/update.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// import consola from 'consola'
import * as ezSpawn from '@jsdevtools/ez-spawn'
import consola from 'consola'
import Prompts from 'prompts'
import { ExitCode } from '../cli/exit-code'
import { NpmScript, copyFiles, deleteFolder } from '../../../src'
import { NpmScript, copyFiles, deleteFolder } from '../../../core'
import { runNpmScript } from './run-npm-script'

const { prompts } = Prompts
Expand Down
Loading

0 comments on commit a70cd79

Please sign in to comment.