-
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
Open
agibson-godaddy
wants to merge
46
commits into
master
Choose a base branch
from
mwc-17961
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
1054f7f
Replace instances of require() with import
agibson-godaddy f1be39f
Move config to separate file that we can export
agibson-godaddy 67e1f65
Initialize config from inside sake file
agibson-godaddy ea38b7a
Refactor replacement pipes
agibson-godaddy b9ad28d
Export scripts
agibson-godaddy d05267b
Refactor validation task
agibson-godaddy 95ae9ed
Refactor bump task
agibson-godaddy d6cb231
Rework wc tasks
agibson-godaddy a6a6826
Only import the fs function we use
agibson-godaddy 742c38a
Rework config task
agibson-godaddy b20d287
Rework linting
agibson-godaddy c87cc19
Rework imagemin
agibson-godaddy a8d9bd3
Adjust gulpif import
agibson-godaddy 8f118fe
Rework shell tasks
agibson-godaddy 47a4296
Rework watch
agibson-godaddy 6e429df
Rework styles
agibson-godaddy 975f55e
Rework makepot
agibson-godaddy 0a99b85
Rework decaffeinate
agibson-godaddy 08d14e1
Rework clean tasks
agibson-godaddy 2182c87
Rework compile task
agibson-godaddy f1ff8e8
Rework scripts
agibson-godaddy 0f20169
Rework github tasks
agibson-godaddy d235325
Rework zip
agibson-godaddy 75f1ebb
Rework prompt
agibson-godaddy 40a5a55
Rework bundle
agibson-godaddy 06141a6
Use task suffix in constants
agibson-godaddy beafea5
Use task suffix
agibson-godaddy 5c517b0
Use task suffix
agibson-godaddy e1c28d6
Use task suffix
agibson-godaddy a68bfe0
Use task suffix
agibson-godaddy 0370715
Start reworking deploy
agibson-godaddy 59a5cca
Rework deploy tasks
agibson-godaddy d0bae0f
Update prerelease tasks
agibson-godaddy c0a821b
Update upfw tasks
agibson-godaddy 1291ccd
Update naming
agibson-godaddy 0212867
Update naming
agibson-godaddy c79a6e0
Fix import
agibson-godaddy c1ccfcf
Update deprecated sass import
agibson-godaddy 2b08904
Remove console log
agibson-godaddy df04967
Rework how series is created
agibson-godaddy d72c2ba
Add force option
agibson-godaddy 54ba0b3
Fix conflicts
agibson-godaddy bc3f35d
Apply changes from master
agibson-godaddy 4828df1
Apply suggestions from code review
agibson-godaddy b7ba4da
Execute codename as a function
agibson-godaddy 2bb4f13
Fix typo
agibson-godaddy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
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 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 | ||
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)) | ||
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.js
so that it can now be imported where required, instead of passing it around function parameters.