Skip to content

Commit

Permalink
feat: cli arguments support and CJS to ESM conversion (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
lirantal committed Jul 12, 2021
1 parent f512c74 commit 5fab236
Show file tree
Hide file tree
Showing 15 changed files with 5,962 additions and 23,076 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
matrix:
platform: [ubuntu-latest]
node: ['12', '14']
node: ['14', '16']
name: Tests - Node ${{ matrix.node }} (${{ matrix.platform }})
runs-on: ${{ matrix.platform }}
steps:
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__tests__/__fixtures__
9 changes: 0 additions & 9 deletions .prettierrc.js

This file was deleted.

9 changes: 9 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"printWidth": 100,
"tabWidth": 2,
"singleQuote": true,
"semi": false,
"trailingComma": "none",
"useTabs": false,
"bracketSpacing": true
}
Binary file not shown.
14 changes: 8 additions & 6 deletions __tests__/app.test.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
const fs = require('fs')
const path = require('path')
const { testProject } = require('../src')

const decompress = require('decompress')
import fs from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'
import { testProject } from '../src/main.js'
import decompress from 'decompress'
import { jest } from '@jest/globals'

jest.setTimeout(30000)
const __dirname = path.dirname(fileURLToPath(import.meta.url))

const projectFixtures = [
'simple-project.zip',
'small-project.zip',
'commit-with-broken-package-json.zip',
'small-project-existing-package-name.zip'
'simple-project-existing-package-name.zip'
]

const destinationFixtures = path.resolve(path.join(__dirname, '__fixtures__', 'tmp'))
Expand Down
12 changes: 12 additions & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "current"
}
}
]
]
}
49 changes: 40 additions & 9 deletions bin/snync.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,55 @@
#!/usr/bin/env node
'use strict'

const path = require('path')
const { argv } = require('process')
const { testProject } = require('../src')
import path from 'path'
import { testProject } from '../src/main.js'
import meow from 'meow'

const cli = meow(
`
Usage
$ snync --directory ~/projects/my-app [options]
Options
--directory -d Path to a project's source-code directory with a package.json
--private -p Specify name of private packages (repeat as needed)
--debug -x Enable debugging when printing data
Examples
$ snync --directory ~/projects/my-app -p "my-private-package-name" -p "my-other-private-package"
`,
{
importMeta: import.meta,
flags: {
directory: {
type: 'string',
alias: 'd'
},
private: {
type: 'string',
alias: 'p'
},
debug: {
type: 'boolean',
alias: 'x'
}
}
}
)

main()

async function main() {
const cmdArguments = argv
let projectPath

if (cmdArguments[2]) {
projectPath = path.resolve(cmdArguments[2])
if (cli.flags.directory) {
projectPath = path.resolve(cli.flags.directory)
console.log(`Testing project at: ${projectPath}`)
} else {
console.error(`Please provide a directory path to the git project to test.`)
console.error(` e.g: /home/user/my-app`)
console.error(`error: please provide a directory path to the git project to test.`)
console.error(cli.help)
process.exit(-1)
}

await testProject({ projectPath, log: console.log })
await testProject({ projectPath, log: console.log, debug: cli.flags.debug })
}
3 changes: 0 additions & 3 deletions index.js

This file was deleted.

Loading

0 comments on commit 5fab236

Please sign in to comment.