Skip to content

Commit fd47601

Browse files
Merge pull request #6 from redvanworkshop/bug/5-sfcc-setup
Fixes #5
2 parents 04c34fd + 871a1c7 commit fd47601

File tree

5 files changed

+143
-53
lines changed

5 files changed

+143
-53
lines changed

commands/setup.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ const chalk = require('chalk')
33
const fs = require('fs')
44
const path = require('path')
55
const prompt = require('prompt')
6-
const slug = require('slug')
76

87
const builds = require('../lib/builds')
98
const config = require('../lib/config')()
9+
const slug = require('../lib/slug')
1010

1111
module.exports = async () => {
1212
const setDefaults =
@@ -117,8 +117,8 @@ module.exports = async () => {
117117
console.log(chalk.red('× ERROR:', err))
118118
}
119119
} else {
120-
const client = slug(result.c, {lower: true, replacement: '-'})
121-
const alias = slug(result.a, {lower: true, replacement: '-'})
120+
const client = slug(result.c)
121+
const alias = slug(result.a)
122122
const currentConfig = config.get()
123123

124124
let newConfig = {}

lib/builds.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ const convert = require('xml-js')
22
const fs = require('fs')
33
const os = require('os').type()
44
const path = require('path')
5-
const slug = require('slug')
5+
6+
const slug = require('./slug')
67

78
module.exports = project => {
89
let externalToolBuilders = []
@@ -32,8 +33,7 @@ module.exports = project => {
3233
const name = slug(
3334
path.basename(path.dirname(path.dirname(launch))).replace('_', '-') +
3435
'_' +
35-
path.basename(launch).replace('.launch', ''),
36-
{lower: true, replacement: '-'}
36+
path.basename(launch).replace('.launch', '')
3737
)
3838

3939
// setup placeholder for this config file

lib/slug.js

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
module.exports = text => {
2+
text = text
3+
.toString()
4+
.toLowerCase()
5+
.trim()
6+
7+
const sets = [
8+
{
9+
to: 'a',
10+
from: '[ÀÁÂÃÄÅÆĀĂĄẠẢẤẦẨẪẬẮẰẲẴẶ]'
11+
},
12+
{
13+
to: 'c',
14+
from: '[ÇĆĈČ]'
15+
},
16+
{
17+
to: 'd',
18+
from: '[ÐĎĐÞ]'
19+
},
20+
{
21+
to: 'e',
22+
from: '[ÈÉÊËĒĔĖĘĚẸẺẼẾỀỂỄỆ]'
23+
},
24+
{
25+
to: 'g',
26+
from: '[ĜĞĢǴ]'
27+
},
28+
{
29+
to: 'h',
30+
from: '[ĤḦ]'
31+
},
32+
{
33+
to: 'i',
34+
from: '[ÌÍÎÏĨĪĮİỈỊ]'
35+
},
36+
{
37+
to: 'j',
38+
from: '[Ĵ]'
39+
},
40+
{
41+
to: 'ij',
42+
from: '[IJ]'
43+
},
44+
{
45+
to: 'k',
46+
from: '[Ķ]'
47+
},
48+
{
49+
to: 'l',
50+
from: '[ĹĻĽŁ]'
51+
},
52+
{
53+
to: 'm',
54+
from: '[Ḿ]'
55+
},
56+
{
57+
to: 'n',
58+
from: '[ÑŃŅŇ]'
59+
},
60+
{
61+
to: 'o',
62+
from: '[ÒÓÔÕÖØŌŎŐỌỎỐỒỔỖỘỚỜỞỠỢǪǬƠ]'
63+
},
64+
{
65+
to: 'oe',
66+
from: '[Œ]'
67+
},
68+
{
69+
to: 'p',
70+
from: '[ṕ]'
71+
},
72+
{
73+
to: 'r',
74+
from: '[ŔŖŘ]'
75+
},
76+
{
77+
to: 's',
78+
from: '[ߌŜŞŠ]'
79+
},
80+
{
81+
to: 't',
82+
from: '[ŢŤ]'
83+
},
84+
{
85+
to: 'u',
86+
from: '[ÙÚÛÜŨŪŬŮŰŲỤỦỨỪỬỮỰƯ]'
87+
},
88+
{
89+
to: 'w',
90+
from: '[ẂŴẀẄ]'
91+
},
92+
{
93+
to: 'x',
94+
from: '[ẍ]'
95+
},
96+
{
97+
to: 'y',
98+
from: '[ÝŶŸỲỴỶỸ]'
99+
},
100+
{
101+
to: 'z',
102+
from: '[ŹŻŽ]'
103+
},
104+
{
105+
to: '-',
106+
from: "[·/_,:;']"
107+
}
108+
]
109+
110+
sets.forEach(set => {
111+
text = text.replace(new RegExp(set.from, 'gi'), set.to)
112+
})
113+
114+
text = text
115+
.toString()
116+
.toLowerCase()
117+
.replace(/\s+/g, '-')
118+
.replace(/&/g, '-and-')
119+
.replace(/[^\w-]+/g, '')
120+
.replace(/--+/g, '-')
121+
.replace(/^-+/, '')
122+
.replace(/-+$/, '')
123+
124+
return text
125+
}

package-lock.json

Lines changed: 11 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@
5151
"husky": "^1.3.1",
5252
"lint-staged": "^8.1.0",
5353
"minimist": "^1.2.0",
54-
"prettier": "^1.15.3",
55-
"slug": "^0.9.3"
54+
"prettier": "^1.15.3"
5655
},
5756
"dependencies": {
5857
"axios": "^0.18.0",

0 commit comments

Comments
 (0)