Skip to content

Commit

Permalink
Merge pull request #130 from ember-learn/indent-style-space
Browse files Browse the repository at this point in the history
unify indent style to space
  • Loading branch information
mansona authored Nov 3, 2023
2 parents 50a1c5f + 02d0b69 commit 6ff1c11
Show file tree
Hide file tree
Showing 30 changed files with 1,376 additions and 1,380 deletions.
4 changes: 0 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,5 @@ insert_final_newline = true
indent_style = space
indent_size = 2

[*.js]
indent_style = tab
indent_size = 2

[*.{diff,md}]
trim_trailing_whitespace = false
46 changes: 23 additions & 23 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
module.exports = {
env: {
es6: true,
node: true,
},
extends: ['eslint:recommended', 'plugin:prettier/recommended', 'plugin:n/recommended'],
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
},
rules: {
'n/no-process-exit': 0,
},
overrides: [
{
files: 'test/**/*',
env: {
mocha: true,
},
rules: {
'n/no-unpublished-import': 0,
},
},
],
env: {
es6: true,
node: true,
},
extends: ['eslint:recommended', 'plugin:prettier/recommended', 'plugin:n/recommended'],
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
},
rules: {
'n/no-process-exit': 0,
},
overrides: [
{
files: 'test/**/*',
env: {
mocha: true,
},
rules: {
'n/no-unpublished-import': 0,
},
},
],
}
170 changes: 85 additions & 85 deletions generate-local.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,97 +12,97 @@ const argv = minimist(process.argv.slice(2))
const { project, version, install } = argv

const exit = function exit() {
console.log(...arguments)
process.exit(1)
console.log(...arguments)
process.exit(1)
}

async function runCmd(cmd, path, args = []) {
console.log(chalk.underline(`Running '${chalk.green(cmd)}' in ${path}`))
const executedCmd = await execa(cmd, args, { cwd: path, shell: true, stdio: 'inherit' })
console.log(chalk.underline(`Running '${chalk.green(cmd)}' in ${path}`))
const executedCmd = await execa(cmd, args, { cwd: path, shell: true, stdio: 'inherit' })

if (executedCmd.failed) {
console.error(executedCmd.stdout)
console.error(executedCmd.stderr)
process.exit(1)
}
if (executedCmd.failed) {
console.error(executedCmd.stdout)
console.error(executedCmd.stderr)
process.exit(1)
}

console.log(executedCmd.stdout + '\n')
console.log(executedCmd.stdout + '\n')
}

;(async () => {
if (!project || !version) {
exit(
chalk.red('Both project and version args are required.\n'),
chalk.yellow(' e.g., yarn gen --project ember --version 3.10.1'),
)
}

if (!['ember', 'ember-data'].includes(project)) {
exit(chalk.red(`Project has to be either 'ember' or 'ember-data'. (was given ${project})\n`))
}

try {
await commandExists('yarn')
} catch (e) {
exit(chalk.red('We need yarn installed globally for this script to work'))
}

let emberProjectPath = path.join(__dirname, '../', 'ember.js')
let emberDataProjectPath = path.join(__dirname, '../', 'data')

let checkIfProjectDirExists = dirPath => {
if (!existsSync(dirPath)) {
exit(chalk.yellow(`Please checkout the ${project} project at ${dirPath}`))
}
}

let buildDocs = async projDirPath => {
checkIfProjectDirExists(projDirPath)

if (project === 'ember') {
await runCmd('volta', projDirPath, ['run', 'yarn'])
} else {
await runCmd('corepack', projDirPath, ['pnpm', 'install'])
}

if (install) {
await runCmd(project === 'ember' ? 'yarn' : 'pnpm install', projDirPath)
console.log('\n\n')
}

await runCmd(
project === 'ember' ? 'volta run yarn docs' : 'corepack pnpm run build:docs',
projDirPath,
)

let destination = `${docsPath}/s3-docs/v${version}/${project}-docs.json`
ensureFileSync(destination)
const projYuiDocFile = destination
removeSync(projYuiDocFile)
removeSync(`${docsPath}/json-docs/${project}/${version}`)

const yuiDocFile = path.join(
projDirPath,
project === 'ember' ? 'docs/data.json' : 'packages/-ember-data/dist/docs/data.json',
)
copyFileSync(yuiDocFile, projYuiDocFile)
}

let dirMap = {
ember: emberProjectPath,
'ember-data': emberDataProjectPath,
}

await buildDocs(dirMap[project])

await execa('volta', [
'run',
'yarn',
'start',
'--project',
project,
'--version',
version,
'--no-sync',
]).stdout.pipe(process.stdout)
if (!project || !version) {
exit(
chalk.red('Both project and version args are required.\n'),
chalk.yellow(' e.g., yarn gen --project ember --version 3.10.1'),
)
}

if (!['ember', 'ember-data'].includes(project)) {
exit(chalk.red(`Project has to be either 'ember' or 'ember-data'. (was given ${project})\n`))
}

try {
await commandExists('yarn')
} catch (e) {
exit(chalk.red('We need yarn installed globally for this script to work'))
}

let emberProjectPath = path.join(__dirname, '../', 'ember.js')
let emberDataProjectPath = path.join(__dirname, '../', 'data')

let checkIfProjectDirExists = dirPath => {
if (!existsSync(dirPath)) {
exit(chalk.yellow(`Please checkout the ${project} project at ${dirPath}`))
}
}

let buildDocs = async projDirPath => {
checkIfProjectDirExists(projDirPath)

if (project === 'ember') {
await runCmd('volta', projDirPath, ['run', 'yarn'])
} else {
await runCmd('corepack', projDirPath, ['pnpm', 'install'])
}

if (install) {
await runCmd(project === 'ember' ? 'yarn' : 'pnpm install', projDirPath)
console.log('\n\n')
}

await runCmd(
project === 'ember' ? 'volta run yarn docs' : 'corepack pnpm run build:docs',
projDirPath,
)

let destination = `${docsPath}/s3-docs/v${version}/${project}-docs.json`
ensureFileSync(destination)
const projYuiDocFile = destination
removeSync(projYuiDocFile)
removeSync(`${docsPath}/json-docs/${project}/${version}`)

const yuiDocFile = path.join(
projDirPath,
project === 'ember' ? 'docs/data.json' : 'packages/-ember-data/dist/docs/data.json',
)
copyFileSync(yuiDocFile, projYuiDocFile)
}

let dirMap = {
ember: emberProjectPath,
'ember-data': emberDataProjectPath,
}

await buildDocs(dirMap[project])

await execa('volta', [
'run',
'yarn',
'start',
'--project',
project,
'--version',
version,
'--no-sync',
]).stdout.pipe(process.stdout)
})()
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const argv = require('minimist')(process.argv.slice(2))

let possibleProjects = ['ember', 'ember-data']
let projects =
argv.project && possibleProjects.includes(argv.project) ? [argv.project] : possibleProjects
argv.project && possibleProjects.includes(argv.project) ? [argv.project] : possibleProjects
let specificDocsVersion = argv.version ? argv.version : ''

let runClean = !!argv.clean
Expand Down
74 changes: 37 additions & 37 deletions lib/add-inherited-items.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
import _ from 'lodash'

export default function addInheritedItems(docSets) {
docSets.forEach(versionData => {
let data = versionData.data
let classes = _.values(data.classes).filter(klass => klass && klass.name)
classes = classes.filter(removeLongDocsBecauseEmber1HasWeirdDocs)
let classItems = data.classitems.filter(({ itemtype }) => itemtype)
docSets.forEach(versionData => {
let data = versionData.data
let classes = _.values(data.classes).filter(klass => klass && klass.name)
classes = classes.filter(removeLongDocsBecauseEmber1HasWeirdDocs)
let classItems = data.classitems.filter(({ itemtype }) => itemtype)

classes.forEach(klass => {
let parents = getParents(klass, classes)
classes.forEach(klass => {
let parents = getParents(klass, classes)

for (let i = 0; i < parents.length; ++i) {
parents = parents.concat(getParents(parents[i], classes))
}
parents.forEach(parent => {
if (!parent) return
let parentItems = classItems.filter(item => item.class === parent.name)
parentItems = parentItems.map(item => {
item = _.clone(item)
item.inherited = true
item.inheritedFrom = item.class
item.class = klass.name
return item
})
data.classitems = data.classitems.concat(parentItems)
})
})
})
for (let i = 0; i < parents.length; ++i) {
parents = parents.concat(getParents(parents[i], classes))
}
parents.forEach(parent => {
if (!parent) return
let parentItems = classItems.filter(item => item.class === parent.name)
parentItems = parentItems.map(item => {
item = _.clone(item)
item.inherited = true
item.inheritedFrom = item.class
item.class = klass.name
return item
})
data.classitems = data.classitems.concat(parentItems)
})
})
})

return Promise.resolve(docSets)
return Promise.resolve(docSets)
}

function getParents(klass, classes) {
let parents = []
if (klass.extends) {
parents = parents.concat([klass.extends])
}
if (klass.uses && klass.uses.length) {
parents = parents.concat(klass.uses.reverse())
}
return parents
.map(parent => _.find(classes, ({ name }) => name === parent))
.filter(parent => parent)
let parents = []
if (klass.extends) {
parents = parents.concat([klass.extends])
}
if (klass.uses && klass.uses.length) {
parents = parents.concat(klass.uses.reverse())
}
return parents
.map(parent => _.find(classes, ({ name }) => name === parent))
.filter(parent => parent)
}

function removeLongDocsBecauseEmber1HasWeirdDocs({ name }) {
let str = 'A Suite can'
return !name.includes(str)
let str = 'A Suite can'
return !name.includes(str)
}
Loading

0 comments on commit 6ff1c11

Please sign in to comment.