-
Notifications
You must be signed in to change notification settings - Fork 0
Convert code base to ESM #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1054f7f
f1be39f
67e1f65
ea38b7a
b9ad28d
d05267b
95ae9ed
d6cb231
a6a6826
742c38a
b20d287
c87cc19
a8d9bd3
8f118fe
47a4296
6e429df
975f55e
0a99b85
08d14e1
2182c87
f1ff8e8
0f20169
d235325
75f1ebb
40a5a55
06141a6
beafea5
5c517b0
e1c28d6
a68bfe0
0370715
59a5cca
d0bae0f
c0a821b
1291ccd
0212867
c79a6e0
c1ccfcf
2b08904
df04967
d72c2ba
54ba0b3
bc3f35d
4828df1
b7ba4da
2bb4f13
d10d31c
17ce641
389eee0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| import path from 'node:path' | ||
| import { existsSync } from 'node:fs' | ||
| import log from 'fancy-log' | ||
| import _ from 'lodash' | ||
| import { createRequire } from 'node:module' | ||
| const require = createRequire(import.meta.url); | ||
|
|
||
| const buildSakeConfig = () => { | ||
| // define default config | ||
| let defaults = { | ||
| // sets up the plugin folder structure | ||
| paths: { | ||
| // Path to plugin source files - this is where the main plugin entry file is located. Set this to a dot (.) if the | ||
| // main plugin file and sake.config.js are in teh same directory. The path is relative to the current working directory. | ||
| // Mostly, this is the only path a plugin/repo needs to explicitly set | ||
| src: '.', | ||
| // where plugin assets are located, relative to `src` | ||
| assets: 'assets', | ||
| // where plugin CSS/SCSS assets are located, relative to `src` | ||
| css: 'assets/css', | ||
| // where plugin JS/COFFEE assets are located, relative to `src` | ||
| js: 'assets/js', | ||
| // where plugin JS vendor assets are located, relative to `js` | ||
| jsVendor: 'vendor', | ||
| // where plugin image assets are located, relative to `src` | ||
| images: 'assets/img', | ||
| // where plugin font assets are located, relative to `src` | ||
| fonts: 'assets/fonts', | ||
| // the directory where plugin files are copied during the build task, relative to current working directory | ||
| build: 'build', | ||
| // path to the directory where production (WC and WP.org SVN) repos are cloned, may be an absolute path or relative to current working directory | ||
| tmp: '/tmp/sake', | ||
| // array of paths that should be excluded from the build | ||
| exclude: [] | ||
| }, | ||
|
|
||
| // Task-specific settings, set the key to task name and provide any settings as needed. Since sake uses Gulp behind the scenes | ||
| // and Gulp prefers code over configuration, there isn't a lot to do here. As you can see, some of these values can be defined | ||
| // as environment variables, as this makes more sense - ie whether you want to use browsersync or not is specific tp your local | ||
| // dev environment and workflow, not to a particular repo. | ||
| tasks: { | ||
| makepot: { | ||
| reportBugsTo: 'https://woocommerce.com/my-account/marketplace-ticket-form/', | ||
| domainPath: 'i18n/languages' | ||
| }, | ||
| watch: { | ||
| useBrowserSync: process.env.USE_BROWSERSYNC || false | ||
| }, | ||
| browserSync: { | ||
| url: process.env.BROWSERSYNC_URL || 'plugins-skyverge.test' | ||
| } | ||
| }, | ||
|
|
||
| // which framework version this plugin uses - valid values: 'v5', 'v4', or pass boolean `false` to indicate a non-frameworked plugin | ||
| framework: 'v5', | ||
| // which deploy type does this plugin use - either 'wc' or 'wp', defaults to 'wc', specify `null` or `false` for no automated deploy | ||
| deploy: 'wc', | ||
| // the e-commerce platform this plugin is for, 'wc' or 'edd' | ||
| platform: 'wc' | ||
| } | ||
|
|
||
| // load local configuration | ||
| // TODO: allow passing in config file path or config as string (for multi-plugin repos?) | ||
| let localConfig = {} | ||
|
|
||
| // support supplying a single / parent config file in multi-plugin repos | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @agibson-godaddy do we still need to support this after restructuring the Memberships add-on repos?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can handle that for a separate discussion. We no longer need it, but I think the greater question is who we're maintaining this for (just ourselves? others?) Do we care about removing that if people-who-are-not-us might be using it? Regardless of what the answer is, I think we can make that a separate discussion and PR. This change might also tie into the below comment about versioning Sake / major version release. |
||
| let parentConfigPath = path.join(process.cwd(), '../sake.config.js') | ||
| let found = false | ||
|
|
||
| if (existsSync(parentConfigPath)) { | ||
| log.warn('Found config file in parent folder') | ||
| localConfig = require(parentConfigPath) | ||
| found = true | ||
| } | ||
|
|
||
| // load local, plugin-specific config file | ||
| let configFilePath = path.join(process.cwd(), 'sake.config.js') | ||
|
|
||
| if (existsSync(configFilePath)) { | ||
| localConfig = _.merge(localConfig, require(configFilePath)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have any interest in updating If so I think we'll need to replace our
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thinking let's do it later? I didn't want to make a change in sake that required
tl;dr trying to avoid breaking changes |
||
| found = true | ||
| } | ||
|
|
||
| if (!found) { | ||
| log.warn('Could not find local config file, using default config values.') | ||
| } | ||
|
|
||
| return _.merge(defaults, localConfig) | ||
| } | ||
|
|
||
| const sakeConfig = buildSakeConfig(); | ||
|
|
||
| export default sakeConfig; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Config was moved to new, separate file
lib/config.jsso that it can now be imported where required, instead of passing it around function parameters.