@by-association-only/cli 2.3.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +453 -0
- package/dist/index.mjs +436 -0
- package/package.json +38 -21
- package/.idea/bao-cli.iml +0 -12
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/inspectionProfiles/Project_Default.xml +0 -155
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
- package/.nvmrc +0 -1
- package/commands/create/git.js +0 -59
- package/commands/create/index.js +0 -123
- package/commands/create/local.js +0 -151
- package/commands/create/theme.js +0 -134
- package/commands/get-live-theme-id/index.js +0 -33
- package/config/index.js +0 -24
- package/index.js +0 -102
- package/utils.js +0 -14
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
<component name="InspectionProjectProfileManager">
|
|
2
|
-
<profile version="1.0">
|
|
3
|
-
<option name="myName" value="Project Default" />
|
|
4
|
-
<inspection_tool class="CheckEmptyScriptTag" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
5
|
-
<inspection_tool class="CssInvalidFunction" enabled="false" level="ERROR" enabled_by_default="false" />
|
|
6
|
-
<inspection_tool class="CssInvalidPropertyValue" enabled="false" level="ERROR" enabled_by_default="false" />
|
|
7
|
-
<inspection_tool class="CssOptimizeSimilarProperties" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
|
8
|
-
<inspection_tool class="CssUnknownProperty" enabled="true" level="WARNING" enabled_by_default="true">
|
|
9
|
-
<option name="myCustomPropertiesEnabled" value="true" />
|
|
10
|
-
<option name="myIgnoreVendorSpecificProperties" value="false" />
|
|
11
|
-
<option name="myCustomPropertiesList">
|
|
12
|
-
<value>
|
|
13
|
-
<list size="4">
|
|
14
|
-
<item index="0" class="java.lang.String" itemvalue="font-awesome" />
|
|
15
|
-
<item index="1" class="java.lang.String" itemvalue="padding-inline-start" />
|
|
16
|
-
<item index="2" class="java.lang.String" itemvalue="font-awesone" />
|
|
17
|
-
<item index="3" class="java.lang.String" itemvalue="appearance" />
|
|
18
|
-
</list>
|
|
19
|
-
</value>
|
|
20
|
-
</option>
|
|
21
|
-
</inspection_tool>
|
|
22
|
-
<inspection_tool class="Eslint" enabled="true" level="ERROR" enabled_by_default="true" />
|
|
23
|
-
<inspection_tool class="HtmlUnknownAttribute" enabled="true" level="WARNING" enabled_by_default="true">
|
|
24
|
-
<option name="myValues">
|
|
25
|
-
<value>
|
|
26
|
-
<list size="28">
|
|
27
|
-
<item index="0" class="java.lang.String" itemvalue=":href" />
|
|
28
|
-
<item index="1" class="java.lang.String" itemvalue=":key" />
|
|
29
|
-
<item index="2" class="java.lang.String" itemvalue=":value" />
|
|
30
|
-
<item index="3" class="java.lang.String" itemvalue="@change" />
|
|
31
|
-
<item index="4" class="java.lang.String" itemvalue=":aria-selected" />
|
|
32
|
-
<item index="5" class="java.lang.String" itemvalue="@click" />
|
|
33
|
-
<item index="6" class="java.lang.String" itemvalue=":placeholder" />
|
|
34
|
-
<item index="7" class="java.lang.String" itemvalue="@input" />
|
|
35
|
-
<item index="8" class="java.lang.String" itemvalue="ref" />
|
|
36
|
-
<item index="9" class="java.lang.String" itemvalue=":default" />
|
|
37
|
-
<item index="10" class="java.lang.String" itemvalue=":items" />
|
|
38
|
-
<item index="11" class="java.lang.String" itemvalue=":default-filter" />
|
|
39
|
-
<item index="12" class="java.lang.String" itemvalue="@selectedfilter" />
|
|
40
|
-
<item index="13" class="java.lang.String" itemvalue=":label" />
|
|
41
|
-
<item index="14" class="java.lang.String" itemvalue=":src" />
|
|
42
|
-
<item index="15" class="java.lang.String" itemvalue="@click.stop" />
|
|
43
|
-
<item index="16" class="java.lang.String" itemvalue=":class" />
|
|
44
|
-
<item index="17" class="java.lang.String" itemvalue=":style" />
|
|
45
|
-
<item index="18" class="java.lang.String" itemvalue=":data-fixed-nav-location" />
|
|
46
|
-
<item index="19" class="java.lang.String" itemvalue=":aria-current" />
|
|
47
|
-
<item index="20" class="java.lang.String" itemvalue=":data-nav-location" />
|
|
48
|
-
<item index="21" class="java.lang.String" itemvalue=":selected" />
|
|
49
|
-
<item index="22" class="java.lang.String" itemvalue="aria-current" />
|
|
50
|
-
<item index="23" class="java.lang.String" itemvalue=":action" />
|
|
51
|
-
<item index="24" class="java.lang.String" itemvalue="@keyup.esc" />
|
|
52
|
-
<item index="25" class="java.lang.String" itemvalue="scope" />
|
|
53
|
-
<item index="26" class="java.lang.String" itemvalue="slot" />
|
|
54
|
-
<item index="27" class="java.lang.String" itemvalue="class" />
|
|
55
|
-
</list>
|
|
56
|
-
</value>
|
|
57
|
-
</option>
|
|
58
|
-
<option name="myCustomValuesEnabled" value="true" />
|
|
59
|
-
</inspection_tool>
|
|
60
|
-
<inspection_tool class="HtmlUnknownTag" enabled="true" level="WARNING" enabled_by_default="true">
|
|
61
|
-
<option name="myValues">
|
|
62
|
-
<value>
|
|
63
|
-
<list size="56">
|
|
64
|
-
<item index="0" class="java.lang.String" itemvalue="nobr" />
|
|
65
|
-
<item index="1" class="java.lang.String" itemvalue="noembed" />
|
|
66
|
-
<item index="2" class="java.lang.String" itemvalue="comment" />
|
|
67
|
-
<item index="3" class="java.lang.String" itemvalue="noscript" />
|
|
68
|
-
<item index="4" class="java.lang.String" itemvalue="embed" />
|
|
69
|
-
<item index="5" class="java.lang.String" itemvalue="script" />
|
|
70
|
-
<item index="6" class="java.lang.String" itemvalue="scroll-indicator" />
|
|
71
|
-
<item index="7" class="java.lang.String" itemvalue="people-list" />
|
|
72
|
-
<item index="8" class="java.lang.String" itemvalue="news-list" />
|
|
73
|
-
<item index="9" class="java.lang.String" itemvalue="transition-group" />
|
|
74
|
-
<item index="10" class="java.lang.String" itemvalue="inline-cta" />
|
|
75
|
-
<item index="11" class="java.lang.String" itemvalue="news-item" />
|
|
76
|
-
<item index="12" class="java.lang.String" itemvalue="company-list" />
|
|
77
|
-
<item index="13" class="java.lang.String" itemvalue="search" />
|
|
78
|
-
<item index="14" class="java.lang.String" itemvalue="companies" />
|
|
79
|
-
<item index="15" class="java.lang.String" itemvalue="companies-list" />
|
|
80
|
-
<item index="16" class="java.lang.String" itemvalue="count-up" />
|
|
81
|
-
<item index="17" class="java.lang.String" itemvalue="filter" />
|
|
82
|
-
<item index="18" class="java.lang.String" itemvalue="button-filter" />
|
|
83
|
-
<item index="19" class="java.lang.String" itemvalue="document-list" />
|
|
84
|
-
<item index="20" class="java.lang.String" itemvalue="frontend-switcher" />
|
|
85
|
-
<item index="21" class="java.lang.String" itemvalue="image-expander" />
|
|
86
|
-
<item index="22" class="java.lang.String" itemvalue="fixed-nav" />
|
|
87
|
-
<item index="23" class="java.lang.String" itemvalue="mobile-nav" />
|
|
88
|
-
<item index="24" class="java.lang.String" itemvalue="transition" />
|
|
89
|
-
<item index="25" class="java.lang.String" itemvalue="card-carousel" />
|
|
90
|
-
<item index="26" class="java.lang.String" itemvalue="card" />
|
|
91
|
-
<item index="27" class="java.lang.String" itemvalue="slot" />
|
|
92
|
-
<item index="28" class="java.lang.String" itemvalue="google-map" />
|
|
93
|
-
<item index="29" class="java.lang.String" itemvalue="navigation" />
|
|
94
|
-
<item index="30" class="java.lang.String" itemvalue="navigation-transition" />
|
|
95
|
-
<item index="31" class="java.lang.String" itemvalue="parallax-items" />
|
|
96
|
-
<item index="32" class="java.lang.String" itemvalue="parallax-item" />
|
|
97
|
-
<item index="33" class="java.lang.String" itemvalue="parallax-layers" />
|
|
98
|
-
<item index="34" class="java.lang.String" itemvalue="global-search" />
|
|
99
|
-
<item index="35" class="java.lang.String" itemvalue="message-attachments" />
|
|
100
|
-
<item index="36" class="java.lang.String" itemvalue="parallax-images" />
|
|
101
|
-
<item index="37" class="java.lang.String" itemvalue="site-header" />
|
|
102
|
-
<item index="38" class="java.lang.String" itemvalue="multiselect" />
|
|
103
|
-
<item index="39" class="java.lang.String" itemvalue="router-view" />
|
|
104
|
-
<item index="40" class="java.lang.String" itemvalue="router-link" />
|
|
105
|
-
<item index="41" class="java.lang.String" itemvalue="futily-header" />
|
|
106
|
-
<item index="42" class="java.lang.String" itemvalue="player-card" />
|
|
107
|
-
<item index="43" class="java.lang.String" itemvalue="page-header" />
|
|
108
|
-
<item index="44" class="java.lang.String" itemvalue="page-bar" />
|
|
109
|
-
<item index="45" class="java.lang.String" itemvalue="lazy-image" />
|
|
110
|
-
<item index="46" class="java.lang.String" itemvalue="resources" />
|
|
111
|
-
<item index="47" class="java.lang.String" itemvalue="resource" />
|
|
112
|
-
<item index="48" class="java.lang.String" itemvalue="component" />
|
|
113
|
-
<item index="49" class="java.lang.String" itemvalue="story-list" />
|
|
114
|
-
<item index="50" class="java.lang.String" itemvalue="stories" />
|
|
115
|
-
<item index="51" class="java.lang.String" itemvalue="story" />
|
|
116
|
-
<item index="52" class="java.lang.String" itemvalue="applyform" />
|
|
117
|
-
<item index="53" class="java.lang.String" itemvalue="apply-form" />
|
|
118
|
-
<item index="54" class="java.lang.String" itemvalue="cards" />
|
|
119
|
-
<item index="55" class="java.lang.String" itemvalue="dashboard-nav" />
|
|
120
|
-
</list>
|
|
121
|
-
</value>
|
|
122
|
-
</option>
|
|
123
|
-
<option name="myCustomValuesEnabled" value="true" />
|
|
124
|
-
</inspection_tool>
|
|
125
|
-
<inspection_tool class="JSXNamespaceValidation" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
|
126
|
-
<inspection_tool class="PostCssCustomProperties" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
127
|
-
<inspection_tool class="PyArgumentListInspection" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
128
|
-
<inspection_tool class="PyClassHasNoInitInspection" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
|
129
|
-
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
|
130
|
-
<option name="ignoredPackages">
|
|
131
|
-
<value>
|
|
132
|
-
<list size="4">
|
|
133
|
-
<item index="0" class="java.lang.String" itemvalue="onespacemedia-server-management" />
|
|
134
|
-
<item index="1" class="java.lang.String" itemvalue="ansible" />
|
|
135
|
-
<item index="2" class="java.lang.String" itemvalue="cms" />
|
|
136
|
-
<item index="3" class="java.lang.String" itemvalue="pymssql" />
|
|
137
|
-
</list>
|
|
138
|
-
</value>
|
|
139
|
-
</option>
|
|
140
|
-
</inspection_tool>
|
|
141
|
-
<inspection_tool class="PyPep8Inspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
|
142
|
-
<option name="ignoredErrors">
|
|
143
|
-
<list>
|
|
144
|
-
<option value="E501" />
|
|
145
|
-
</list>
|
|
146
|
-
</option>
|
|
147
|
-
</inspection_tool>
|
|
148
|
-
<inspection_tool class="RequiredAttributes" enabled="true" level="WARNING" enabled_by_default="true">
|
|
149
|
-
<option name="myAdditionalRequiredHtmlAttributes" value="src,v-else" />
|
|
150
|
-
</inspection_tool>
|
|
151
|
-
<inspection_tool class="SassScssResolvedByNameOnly" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
|
152
|
-
<inspection_tool class="SillyAssignmentJS" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
153
|
-
<inspection_tool class="Stylelint" enabled="true" level="ERROR" enabled_by_default="true" />
|
|
154
|
-
</profile>
|
|
155
|
-
</component>
|
package/.idea/modules.xml
DELETED
package/.idea/vcs.xml
DELETED
package/.nvmrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
14.15.0
|
package/commands/create/git.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
const { Octokit } = require('@octokit/rest')
|
|
2
|
-
const slugify = require('@sindresorhus/slugify')
|
|
3
|
-
|
|
4
|
-
const { spawnPromise } = require('../../utils')
|
|
5
|
-
|
|
6
|
-
class CreateGit {
|
|
7
|
-
constructor (create) {
|
|
8
|
-
this.create = create
|
|
9
|
-
this.octokit = new Octokit({
|
|
10
|
-
auth: this.githubToken
|
|
11
|
-
})
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
async createRepo () {
|
|
15
|
-
this.create.renderStepTitle('Creating project on Github')
|
|
16
|
-
|
|
17
|
-
try {
|
|
18
|
-
const project = await this.createRemoteRepository()
|
|
19
|
-
|
|
20
|
-
console.log(` ✔ created project on Github`)
|
|
21
|
-
|
|
22
|
-
await spawnPromise('git', ['remote', 'add', 'origin', project.data.ssh_url], this.options)
|
|
23
|
-
await spawnPromise('git', ['push', '-u', 'origin', 'master'], this.options)
|
|
24
|
-
console.log(` ✔ pushed master`)
|
|
25
|
-
|
|
26
|
-
this.create.renderStepSuccess('Github project has been created and pushed up')
|
|
27
|
-
} catch (e) {
|
|
28
|
-
this.create.renderStepError('Github project creation failed', e)
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
createRemoteRepository () {
|
|
33
|
-
return this.octokit.repos.createInOrg({
|
|
34
|
-
org: this.organizationName,
|
|
35
|
-
name: this.repoName,
|
|
36
|
-
private: true,
|
|
37
|
-
})
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
get githubToken () {
|
|
41
|
-
return this.create.config.githubToken
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
get options () {
|
|
45
|
-
return { cwd: this.create.localProjectLocation }
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
get organizationName () {
|
|
49
|
-
return this.create.config.organizationName
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
get repoName () {
|
|
53
|
-
return slugify(this.create.answers.projectName)
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
module.exports = {
|
|
58
|
-
CreateGit,
|
|
59
|
-
}
|
package/commands/create/index.js
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
|
-
const os = require('os')
|
|
3
|
-
require('dotenv').config({ path: `${os.homedir()}/.env` })
|
|
4
|
-
|
|
5
|
-
const kleur = require('kleur')
|
|
6
|
-
const slugify = require('@sindresorhus/slugify')
|
|
7
|
-
const Shopify = require('shopify-api-node')
|
|
8
|
-
|
|
9
|
-
const { Config } = require('../../config')
|
|
10
|
-
const { CreateGit } = require('./git')
|
|
11
|
-
const { CreateLocal } = require('./local')
|
|
12
|
-
const { CreateTheme } = require('./theme')
|
|
13
|
-
|
|
14
|
-
class Create {
|
|
15
|
-
constructor (answers) {
|
|
16
|
-
this.config = new Config()
|
|
17
|
-
this.answers = answers
|
|
18
|
-
this.shopify = new Shopify({
|
|
19
|
-
shopName: this.shopName,
|
|
20
|
-
apiKey: this.answers.apiKey,
|
|
21
|
-
password: this.answers.password,
|
|
22
|
-
apiVersion: this.answers.apiVersion
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
this.start()
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async start () {
|
|
29
|
-
try {
|
|
30
|
-
const git = new CreateGit(this)
|
|
31
|
-
const local = new CreateLocal(this)
|
|
32
|
-
const theme = new CreateTheme(this)
|
|
33
|
-
|
|
34
|
-
await local.checkDependencies()
|
|
35
|
-
await local.cloneStarterTheme()
|
|
36
|
-
await local.removeGitFolder()
|
|
37
|
-
await local.initialiseGit()
|
|
38
|
-
await local.doInitialCommits()
|
|
39
|
-
await local.initialiseYarn()
|
|
40
|
-
|
|
41
|
-
await theme.uploadThemes()
|
|
42
|
-
|
|
43
|
-
await git.createRepo()
|
|
44
|
-
|
|
45
|
-
this.finish(theme.themes.develop.id)
|
|
46
|
-
} catch (e) {
|
|
47
|
-
console.log(e)
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
renderStepTitle (title) {
|
|
52
|
-
console.log('\n' + kleur.magenta().bold().underline(title))
|
|
53
|
-
|
|
54
|
-
return this
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
renderStepSuccess (text) {
|
|
58
|
-
console.log('\n' + kleur.green().bold(`✔ ${text}`))
|
|
59
|
-
|
|
60
|
-
return this
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
renderStepError (text, error) {
|
|
64
|
-
console.log('\n' + kleur.bgRed().underline(`✖ ${text}`))
|
|
65
|
-
|
|
66
|
-
throw new Error(error)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
finish (devThemeId) {
|
|
70
|
-
fs.writeFileSync(`${this.localProjectLocation}/.env`, this.createEnvContent({
|
|
71
|
-
apiKey: this.answers.apiKey,
|
|
72
|
-
password: this.answers.password,
|
|
73
|
-
themeId: devThemeId,
|
|
74
|
-
addLocalesToIgnore: false
|
|
75
|
-
}))
|
|
76
|
-
fs.writeFileSync(`${this.localProjectLocation}/.env.example`, this.createEnvContent())
|
|
77
|
-
|
|
78
|
-
console.log(kleur.bgGreen().bold(`
|
|
79
|
-
Your .env and .env.example files have been created for you
|
|
80
|
-
Just run \`cd ${this.localProjectLocation} && yarn start\` to get started!`))
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
createEnvContent ({ apiKey = '', password = '', themeId = '', addLocalesToIgnore = true } = {}) {
|
|
84
|
-
return `# The myshopify.com URL to your Shopify store
|
|
85
|
-
UNISIAN_STORE=${this.shopName}
|
|
86
|
-
|
|
87
|
-
# The API key generated from a Private App
|
|
88
|
-
UNISIAN_API_KEY=${apiKey}
|
|
89
|
-
|
|
90
|
-
# The API password generated from a Private App
|
|
91
|
-
UNISIAN_PASSWORD=${password}
|
|
92
|
-
|
|
93
|
-
# The ID of the theme you wish to upload files too
|
|
94
|
-
UNISIAN_THEME_ID=${themeId}
|
|
95
|
-
|
|
96
|
-
# A list of file patterns to ignore, with each list item seperated by ':'
|
|
97
|
-
UNISIAN_IGNORE_FILES=/config/settings_data.json${addLocalesToIgnore ? ':locales/*.json' : ''}`
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
get shopName () {
|
|
101
|
-
if (this.answers.shopName.includes('myshopify.com')) {
|
|
102
|
-
return this.answers.shopName
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return `${this.answers.shopName}.myshopify.com`
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
get localProjectDirectory () {
|
|
109
|
-
return this.config.localProjectDirectory
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
get localProjectLocation () {
|
|
113
|
-
return `${this.localProjectDirectory}/${this.localFolderName}`
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
get localFolderName () {
|
|
117
|
-
return slugify(this.answers.projectName)
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
module.exports = {
|
|
122
|
-
Create,
|
|
123
|
-
}
|
package/commands/create/local.js
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
|
-
|
|
3
|
-
const commandExists = require('command-exists')
|
|
4
|
-
const kleur = require('kleur')
|
|
5
|
-
|
|
6
|
-
const { spawnPromise } = require('../../utils')
|
|
7
|
-
|
|
8
|
-
class CreateLocal {
|
|
9
|
-
constructor (create) {
|
|
10
|
-
this.create = create
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
async checkDependencies () {
|
|
14
|
-
this.create.renderStepTitle('Checking dependencies')
|
|
15
|
-
|
|
16
|
-
let hasGithubToken
|
|
17
|
-
let gitExists
|
|
18
|
-
let yarnExists
|
|
19
|
-
let codeDirectoryExists
|
|
20
|
-
|
|
21
|
-
try {
|
|
22
|
-
hasGithubToken = process.env.GITHUB_TOKEN !== undefined
|
|
23
|
-
} catch (e) {
|
|
24
|
-
hasGithubToken = false
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
try {
|
|
28
|
-
gitExists = await commandExists('git') === 'git'
|
|
29
|
-
} catch (e) {
|
|
30
|
-
gitExists = false
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
try {
|
|
34
|
-
yarnExists = await commandExists('yarn') === 'yarn'
|
|
35
|
-
} catch (e) {
|
|
36
|
-
yarnExists = false
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
try {
|
|
40
|
-
codeDirectoryExists = fs.existsSync(this.localProjectDirectory)
|
|
41
|
-
} catch (e) {
|
|
42
|
-
codeDirectoryExists = false
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const icon = exists => exists
|
|
47
|
-
? kleur.green('✔')
|
|
48
|
-
: kleur.red('✖')
|
|
49
|
-
|
|
50
|
-
console.log(`
|
|
51
|
-
${icon(hasGithubToken)} GITHUB_TOKEN
|
|
52
|
-
${icon(gitExists)} git
|
|
53
|
-
${icon(yarnExists)} yarn
|
|
54
|
-
${icon(codeDirectoryExists)} ~/Code exists`)
|
|
55
|
-
|
|
56
|
-
const passed = (
|
|
57
|
-
hasGithubToken && gitExists && yarnExists && codeDirectoryExists
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
passed
|
|
61
|
-
? this.create.renderStepSuccess('yay dependencies')
|
|
62
|
-
: this.create.renderStepError('Dependencies failed')
|
|
63
|
-
|
|
64
|
-
return passed
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
async cloneStarterTheme () {
|
|
68
|
-
this.create.renderStepTitle('Cloning starter theme')
|
|
69
|
-
|
|
70
|
-
try {
|
|
71
|
-
await spawnPromise(
|
|
72
|
-
'git',
|
|
73
|
-
['clone', '--depth=1', this.starterThemeGitUrl, this.localProjectLocation],
|
|
74
|
-
{ stdio: 'inherit' }
|
|
75
|
-
)
|
|
76
|
-
this.create.renderStepSuccess('yay starter theme')
|
|
77
|
-
} catch (e) {
|
|
78
|
-
this.create.renderStepError(`Git clone failed`, e)
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
async removeGitFolder () {
|
|
83
|
-
this.create.renderStepTitle(`Removing starter theme's .git folder`)
|
|
84
|
-
|
|
85
|
-
try {
|
|
86
|
-
await spawnPromise('rm', ['-r', `.git`], { cwd: this.localProjectLocation })
|
|
87
|
-
|
|
88
|
-
this.create.renderStepSuccess('bye bye .git')
|
|
89
|
-
} catch (e) {
|
|
90
|
-
this.create.renderStepError('Removing .git folder failed', e)
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
async initialiseGit () {
|
|
95
|
-
this.create.renderStepTitle('Git init')
|
|
96
|
-
|
|
97
|
-
try {
|
|
98
|
-
await spawnPromise('git', ['init'], { cwd: this.localProjectLocation })
|
|
99
|
-
|
|
100
|
-
this.create.renderStepSuccess('Git is here')
|
|
101
|
-
} catch (e) {
|
|
102
|
-
this.create.renderStepError('Git init fail', e)
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
async doInitialCommits () {
|
|
107
|
-
this.create.renderStepTitle('Performing initial commits')
|
|
108
|
-
|
|
109
|
-
const options = { cwd: this.localProjectLocation }
|
|
110
|
-
|
|
111
|
-
try {
|
|
112
|
-
await spawnPromise('git', ['add', '.'], options)
|
|
113
|
-
await spawnPromise('git', ['commit', '-m', 'Initial commit'], options)
|
|
114
|
-
console.log(` ✔ master commit`)
|
|
115
|
-
|
|
116
|
-
this.create.renderStepSuccess('Initial commits, DONE')
|
|
117
|
-
} catch (e) {
|
|
118
|
-
this.create.renderStepError('Performing initial commits fail', e)
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
async initialiseYarn () {
|
|
123
|
-
this.create.renderStepTitle('Initialise yarn')
|
|
124
|
-
|
|
125
|
-
const options = { cwd: this.localProjectLocation, stdio: 'inherit' }
|
|
126
|
-
|
|
127
|
-
try {
|
|
128
|
-
await spawnPromise('yarn', [], options)
|
|
129
|
-
|
|
130
|
-
this.create.renderStepSuccess('Spun that yarn')
|
|
131
|
-
} catch (e) {
|
|
132
|
-
this.create.renderStepError('Initialise yarn fail', e)
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
get starterThemeGitUrl () {
|
|
137
|
-
return `git@github.com:baoagency/Shopify-starter-theme.git`
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
get localProjectDirectory () {
|
|
141
|
-
return this.create.localProjectDirectory
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
get localProjectLocation () {
|
|
145
|
-
return this.create.localProjectLocation
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
module.exports = {
|
|
150
|
-
CreateLocal,
|
|
151
|
-
}
|
package/commands/create/theme.js
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
const { Octokit } = require('@octokit/rest')
|
|
2
|
-
|
|
3
|
-
const { spawnPromise } = require('../../utils')
|
|
4
|
-
|
|
5
|
-
class CreateTheme {
|
|
6
|
-
constructor (create) {
|
|
7
|
-
this.create = create
|
|
8
|
-
this.octokit = new Octokit({
|
|
9
|
-
auth: this.githubToken
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
this.themes = {
|
|
13
|
-
live: null,
|
|
14
|
-
staging: null,
|
|
15
|
-
develop: null,
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async uploadThemes () {
|
|
20
|
-
this.create.renderStepTitle('Uploading the live, staging and develop themes')
|
|
21
|
-
|
|
22
|
-
await this.createThemeZip()
|
|
23
|
-
|
|
24
|
-
const repo = await this.createTemporaryZipRepo()
|
|
25
|
-
|
|
26
|
-
await this.createTemporaryDirectory()
|
|
27
|
-
await this.moveZipToTemporaryDirectory()
|
|
28
|
-
|
|
29
|
-
await this.getThemeZipLive(repo.data.ssh_url)
|
|
30
|
-
|
|
31
|
-
const zipUrl = `${repo.data.html_url}/raw/master/starter-theme.zip`
|
|
32
|
-
|
|
33
|
-
console.log(` ℹ creating live theme`)
|
|
34
|
-
this.themes.live = await this.shopify.theme.create({
|
|
35
|
-
name: `${this.answers.themeName} (Live)`,
|
|
36
|
-
src: zipUrl,
|
|
37
|
-
role: 'main',
|
|
38
|
-
})
|
|
39
|
-
console.log(` ✔ live theme`)
|
|
40
|
-
console.log(` ℹ creating staging theme`)
|
|
41
|
-
this.themes.staging = await this.shopify.theme.create({
|
|
42
|
-
name: `${this.answers.themeName} (Staging)`,
|
|
43
|
-
src: zipUrl,
|
|
44
|
-
})
|
|
45
|
-
console.log(` ✔ staging theme`)
|
|
46
|
-
console.log(` ℹ creating development theme`)
|
|
47
|
-
this.themes.develop = await this.shopify.theme.create({
|
|
48
|
-
name: `${this.answers.themeName} (Development)`,
|
|
49
|
-
src: zipUrl,
|
|
50
|
-
})
|
|
51
|
-
console.log(` ✔ development theme`)
|
|
52
|
-
|
|
53
|
-
await this.deleteTemporaryZipRepo()
|
|
54
|
-
|
|
55
|
-
this.create.renderStepSuccess('All themes have been created on the store')
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
createTemporaryZipRepo () {
|
|
59
|
-
return this.octokit.repos.createInOrg({
|
|
60
|
-
org: this.organizationName,
|
|
61
|
-
name: this.repoName
|
|
62
|
-
})
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
deleteTemporaryZipRepo () {
|
|
66
|
-
return this.octokit.repos.delete({
|
|
67
|
-
owner: this.organizationName,
|
|
68
|
-
repo: this.repoName
|
|
69
|
-
})
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
createTemporaryDirectory () {
|
|
73
|
-
return spawnPromise('mkdir', [this.tmpDirectory])
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
createThemeZip () {
|
|
77
|
-
return spawnPromise('yarn', ['zip'], { cwd: this.localProjectLocation, stdio: 'inherit' })
|
|
78
|
-
.catch(err => console.error(err))
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
moveZipToTemporaryDirectory () {
|
|
82
|
-
return spawnPromise('mv', [`${this.localProjectLocation}/starter-theme.zip`, this.zipLocation])
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
async getThemeZipLive (repoOrigin) {
|
|
86
|
-
const options = { cwd: this.tmpDirectory }
|
|
87
|
-
|
|
88
|
-
await spawnPromise('git', ['init'], options)
|
|
89
|
-
await spawnPromise('git', ['add', '.'], options)
|
|
90
|
-
await spawnPromise('git', ['commit', '-m', 'Add ZIP theme'], options)
|
|
91
|
-
await spawnPromise('git', ['remote', 'add', 'origin', repoOrigin], options)
|
|
92
|
-
await spawnPromise('git', ['push', '-u', 'origin', 'master'], options)
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
get answers () {
|
|
96
|
-
return this.create.answers
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
get githubToken () {
|
|
100
|
-
return this.create.config.githubToken
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
get localFolderName () {
|
|
104
|
-
return this.create.localFolderName
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
get localProjectLocation () {
|
|
108
|
-
return this.create.localProjectLocation
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
get organizationName () {
|
|
112
|
-
return this.create.config.organizationName
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
get repoName () {
|
|
116
|
-
return `${this.localFolderName}-Theme-Zip`
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
get shopify () {
|
|
120
|
-
return this.create.shopify
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
get tmpDirectory () {
|
|
124
|
-
return `/tmp/${this.repoName}`
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
get zipLocation () {
|
|
128
|
-
return `/tmp/${this.repoName}/starter-theme.zip`
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
module.exports = {
|
|
133
|
-
CreateTheme
|
|
134
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
|
-
|
|
3
|
-
const unisianEnv = require('@by-association-only/unisian-env')
|
|
4
|
-
const kleur = require('kleur')
|
|
5
|
-
const { fetchMainThemeId } = require('@by-association-only/unisian-sync')
|
|
6
|
-
|
|
7
|
-
module.exports = {
|
|
8
|
-
getLiveThemeId: async function getLiveThemeId (env) {
|
|
9
|
-
try {
|
|
10
|
-
unisianEnv.assign(env)
|
|
11
|
-
} catch (e) {
|
|
12
|
-
console.log(kleur.red(e))
|
|
13
|
-
|
|
14
|
-
process.exit(1)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
try {
|
|
18
|
-
const mainThemeId = await fetchMainThemeId()
|
|
19
|
-
|
|
20
|
-
const fileLocation = `${process.cwd()}/.env.${env}`
|
|
21
|
-
|
|
22
|
-
const file = fs.readFileSync(fileLocation, 'utf-8')
|
|
23
|
-
const newFileContents = file.replace(/^UNISIAN_THEME_ID=(.*)$/gim, `UNISIAN_THEME_ID=${mainThemeId}`)
|
|
24
|
-
|
|
25
|
-
fs.writeFileSync(fileLocation, newFileContents, 'utf-8')
|
|
26
|
-
|
|
27
|
-
console.log(kleur.green(`Successfully updated .env.${env} with current live theme ID (${mainThemeId})`))
|
|
28
|
-
} catch (e) {
|
|
29
|
-
console.log(kleur.red(e))
|
|
30
|
-
|
|
31
|
-
process.exit(1)
|
|
32
|
-
}
|
|
33
|
-
}}
|