How to use @s-ui/helpers - 10 common examples

To help you get started, we’ve selected a few @s-ui/helpers examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SUI-Components / sui / packages / sui-studio / bin / sui-studio-build.js View on Github external
#!/usr/bin/env node
/* eslint no-console:0 */

const {serialSpawn} = require('@s-ui/helpers/cli')
const {join} = require('path')
const fs = require('fs-extra')

console.log('\n', process.env.NODE_ENV, '\n')
process.env.NODE_ENV = process.env.NODE_ENV || 'production'

const bundlerBuildPath = require.resolve('@s-ui/bundler/bin/sui-bundler-build')

serialSpawn([
  [
    bundlerBuildPath,
    ['-C', '--context', join(__dirname, '..', 'src')],
    {shell: false, env: process.env}
  ]
])
  .then(() => fs.copy('public/index.html', 'public/200.html'))
  .then(code => process.exit(code))
  .catch(code => process.exit(code))
github SUI-Components / sui / packages / sui-precommit / bin / sui-precommit-run.js View on Github external
#!/usr/bin/env node

const {serialSpawn} = require('@s-ui/helpers/cli')
const BIN_PATH = require.resolve('@s-ui/lint/bin/sui-lint')

serialSpawn([
  [BIN_PATH, ['js', '--staged']],
  [BIN_PATH, ['sass', '--staged']],
  ['npm', ['run', 'test']]
])
  .then(code => process.exit(code))
  .catch(error => {
    // eslint-disable-next-line no-console
    console.error(error)
    process.exit(1)
  })
github SUI-Components / sui / packages / sui-svg / bin / sui-svg-demo.js View on Github external
/* eslint no-console:0 */
const program = require('commander')
const path = require('path')
const {getSpawnPromise} = require('@s-ui/helpers/cli')

program
  .on('--help', () => {
    console.log('  Description:')
    console.log('')
    console.log('    Shows a demo of your SVG library')
    console.log('')
  })
  .parse(process.argv)

const devServerExec = require.resolve('@s-ui/bundler/bin/sui-bundler-dev')
getSpawnPromise(
  devServerExec,
  ['-c', path.join(__dirname, '..', 'src'), '--no-pre-loader'],
  {
    shell: false,
    env: process.env
  }
).then(process.exit, process.exit)
github SUI-Components / sui / packages / sui-mono / bin / sui-mono-commit-all.js View on Github external
console.log('    Usefull for cross-pacakge refactors.')
    console.log('')
    console.log('  Examples:')
    console.log('')
    console.log(
      '    $ sui-mono commit-all --type=fix -m "bump dependency to major version"'
    )
    console.log('    $ sui-mono --help')
    console.log('    $ sui-mono -h')
    console.log('')
  })
  .parse(process.argv)

// Check mandatory parameters
const {message, type} = program
!message && showError('Commit message is mandatory')
!type && showError('Commit type is mandatory')

const packagesDir = path.join(process.cwd(), config.getPackagesFolder())

/**
 * Checks if given path has changes
 * @param  {String}  path Folder to check
 * @return {Promise}
 */
const hasChangedFiles = path => {
  return new Promise((resolve, reject) => {
    exec(`git add . && git status ${path}`, {cwd: path}, (err, output) => {
      err ? reject(err) : resolve(!output.includes('nothing to commit'))
    })
  })
}
github SUI-Components / sui / packages / sui-mono / bin / sui-mono-commit-all.js View on Github external
console.log('')
    console.log('  Examples:')
    console.log('')
    console.log(
      '    $ sui-mono commit-all --type=fix -m "bump dependency to major version"'
    )
    console.log('    $ sui-mono --help')
    console.log('    $ sui-mono -h')
    console.log('')
  })
  .parse(process.argv)

// Check mandatory parameters
const {message, type} = program
!message && showError('Commit message is mandatory')
!type && showError('Commit type is mandatory')

const packagesDir = path.join(process.cwd(), config.getPackagesFolder())

/**
 * Checks if given path has changes
 * @param  {String}  path Folder to check
 * @return {Promise}
 */
const hasChangedFiles = path => {
  return new Promise((resolve, reject) => {
    exec(`git add . && git status ${path}`, {cwd: path}, (err, output) => {
      err ? reject(err) : resolve(!output.includes('nothing to commit'))
    })
  })
}
github SUI-Components / sui / packages / sui-widget-embedder / bin / sui-widget-embedder-generate.js View on Github external
const packageInfo = require(PAGE_BASE_PROJECT_JSON_FILE)
packageInfo.scripts[`start:${page}`] = `sui-widget-embedder dev -p ${page}`

const {config = {}} = packageInfo
const {sitePrefix = ''} = config['sui-widget-embedder'] || {}

// Check if the page already exist before continuing
if (fs.existsSync(PAGE_PATH)) {
  showError(`[${page}] This page already exist in the path:
  ${PAGE_PATH}`)
}

Promise.all([
  writeFile(PAGE_PACKAGE_JSON_FILE, packageJSON(pageRegExpIdentifier)),
  writeFile(PAGE_ENTRY_JS_POINT_FILE, indexJS()),
  writeFile(PAGE_ENTRY_SCSS_POINT_FILE, indexSCSS(sitePrefix)),
  writeFile(
    PAGE_BASE_PROJECT_JSON_FILE,
    JSON.stringify(packageInfo, null, '  ')
  )
]).then(() => {
  console.log(
    colors.green(
      `➜ [${page}]: Your page files have been generated successfully.`
    )
  )
})
github SUI-Components / sui / packages / sui-widget-embedder / bin / sui-widget-embedder-generate.js View on Github external
packageInfo.scripts[`start:${page}`] = `sui-widget-embedder dev -p ${page}`

const {config = {}} = packageInfo
const {sitePrefix = ''} = config['sui-widget-embedder'] || {}

// Check if the page already exist before continuing
if (fs.existsSync(PAGE_PATH)) {
  showError(`[${page}] This page already exist in the path:
  ${PAGE_PATH}`)
}

Promise.all([
  writeFile(PAGE_PACKAGE_JSON_FILE, packageJSON(pageRegExpIdentifier)),
  writeFile(PAGE_ENTRY_JS_POINT_FILE, indexJS()),
  writeFile(PAGE_ENTRY_SCSS_POINT_FILE, indexSCSS(sitePrefix)),
  writeFile(
    PAGE_BASE_PROJECT_JSON_FILE,
    JSON.stringify(packageInfo, null, '  ')
  )
]).then(() => {
  console.log(
    colors.green(
      `➜ [${page}]: Your page files have been generated successfully.`
    )
  )
})
github SUI-Components / sui / packages / sui-widget-embedder / bin / sui-widget-embedder-generate.js View on Github external
const PAGE_BASE_PROJECT_JSON_FILE = path.join(process.cwd(), 'package.json')
const {pageRegExpIdentifier} = program
const packageInfo = require(PAGE_BASE_PROJECT_JSON_FILE)
packageInfo.scripts[`start:${page}`] = `sui-widget-embedder dev -p ${page}`

const {config = {}} = packageInfo
const {sitePrefix = ''} = config['sui-widget-embedder'] || {}

// Check if the page already exist before continuing
if (fs.existsSync(PAGE_PATH)) {
  showError(`[${page}] This page already exist in the path:
  ${PAGE_PATH}`)
}

Promise.all([
  writeFile(PAGE_PACKAGE_JSON_FILE, packageJSON(pageRegExpIdentifier)),
  writeFile(PAGE_ENTRY_JS_POINT_FILE, indexJS()),
  writeFile(PAGE_ENTRY_SCSS_POINT_FILE, indexSCSS(sitePrefix)),
  writeFile(
    PAGE_BASE_PROJECT_JSON_FILE,
    JSON.stringify(packageInfo, null, '  ')
  )
]).then(() => {
  console.log(
    colors.green(
      `➜ [${page}]: Your page files have been generated successfully.`
    )
  )
})
github SUI-Components / sui / packages / sui-lint / scripts / add-package-json-fields.js View on Github external
const areDifferentLintConfig =
    JSON.stringify({eslintConfig, prettier, stylelint}) !==
    JSON.stringify(LINT_CONFIGS)

  // if they're different, we're going to rewrite the package.json
  if (areDifferentLintConfig) {
    console.log('Adding @s-ui/lint config to package.json...')
    // remove deprecated linter config of sasslintConfig
    const {sasslintConfig, ...originalPackageJSON} = packageJSON
    // create the new package.json object to be written
    const newPackageJSON = {
      ...originalPackageJSON,
      ...LINT_CONFIGS
    }
    // write the new package.json with the linter conifg
    writeFile(
      ACTUAL_PACKAGE_PATH,
      JSON.stringify(newPackageJSON, null, 2)
    ).then(() => console.log('Added @s-ui/lint config successfully'))
  } else {
    console.log('@s-ui/lint config already in your package.json. Great!')
  }
} catch (e) {
  console.log("@s-ui/lint can't update package.json file.")
}
github SUI-Components / sui / packages / sui-widget-embedder / bin / sui-widget-embedder-generate.js View on Github external
const {pageRegExpIdentifier} = program
const packageInfo = require(PAGE_BASE_PROJECT_JSON_FILE)
packageInfo.scripts[`start:${page}`] = `sui-widget-embedder dev -p ${page}`

const {config = {}} = packageInfo
const {sitePrefix = ''} = config['sui-widget-embedder'] || {}

// Check if the page already exist before continuing
if (fs.existsSync(PAGE_PATH)) {
  showError(`[${page}] This page already exist in the path:
  ${PAGE_PATH}`)
}

Promise.all([
  writeFile(PAGE_PACKAGE_JSON_FILE, packageJSON(pageRegExpIdentifier)),
  writeFile(PAGE_ENTRY_JS_POINT_FILE, indexJS()),
  writeFile(PAGE_ENTRY_SCSS_POINT_FILE, indexSCSS(sitePrefix)),
  writeFile(
    PAGE_BASE_PROJECT_JSON_FILE,
    JSON.stringify(packageInfo, null, '  ')
  )
]).then(() => {
  console.log(
    colors.green(
      `➜ [${page}]: Your page files have been generated successfully.`
    )
  )
})