-
Notifications
You must be signed in to change notification settings - Fork 15
chore(release): 4.0.0 #57
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
Closed
Closed
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
node_modules | ||
coverage | ||
lib | ||
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 |
---|---|---|
@@ -1,5 +1,31 @@ | ||
sudo: false | ||
|
||
git: | ||
depth: 10 | ||
|
||
branches: | ||
only: | ||
- master | ||
|
||
language: node_js | ||
node_js: | ||
- "4" | ||
- "6" | ||
- "node" | ||
|
||
# cache node modules | ||
cache: | ||
directories: | ||
- $HOME/.npm | ||
- node_modules | ||
|
||
matrix: | ||
fast_finish: true | ||
include: | ||
- node_js: '10' | ||
script: npm run test -- --no-coverage | ||
- node_js: '8' | ||
script: npm run test -- --no-coverage | ||
- node_js: '6' | ||
script: npm run test -- --no-coverage | ||
|
||
before_install: | ||
- npm install -g npm@latest | ||
- node --version | ||
- npm --version |
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,65 @@ | ||
"use strict"; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
|
||
var _postcss = _interopRequireDefault(require("postcss")); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
const createImports = imports => { | ||
return Object.keys(imports).map(token => { | ||
const aliases = imports[token]; | ||
const declarations = Object.keys(aliases).map(key => _postcss.default.decl({ | ||
prop: key, | ||
value: aliases[key], | ||
raws: { | ||
before: "\n " | ||
} | ||
})); | ||
const hasDeclarations = declarations.length > 0; | ||
|
||
const rule = _postcss.default.rule({ | ||
selector: `:import(${token})`, | ||
raws: { | ||
after: hasDeclarations ? "\n" : "" | ||
} | ||
}); | ||
|
||
if (hasDeclarations) { | ||
rule.append(declarations); | ||
} | ||
|
||
return rule; | ||
}); | ||
}; | ||
|
||
const createExports = exports => { | ||
const declarations = Object.keys(exports).map(key => _postcss.default.decl({ | ||
prop: key, | ||
value: exports[key], | ||
raws: { | ||
before: "\n " | ||
} | ||
})); | ||
|
||
if (declarations.length === 0) { | ||
return []; | ||
} | ||
|
||
const rule = _postcss.default.rule({ | ||
selector: `:export`, | ||
raws: { | ||
after: "\n" | ||
} | ||
}).append(declarations); | ||
|
||
return [rule]; | ||
}; | ||
|
||
const createICSSRules = (imports, exports) => [...createImports(imports), ...createExports(exports)]; | ||
|
||
var _default = createICSSRules; | ||
exports.default = _default; |
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,64 @@ | ||
"use strict"; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
|
||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } | ||
|
||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
|
||
const importPattern = /^:import\(("[^"]*"|'[^']*')(?:\s(.+))?\)$/; | ||
|
||
const getDeclsObject = rule => { | ||
const object = {}; | ||
rule.walkDecls(decl => { | ||
object[decl.raws.before.trim() + decl.prop] = decl.value; | ||
}); | ||
return object; | ||
}; | ||
|
||
const extractICSS = (css, removeRules = true) => { | ||
const icssImports = {}; | ||
const icssExports = {}; | ||
css.each(node => { | ||
if (node.type === "rule") { | ||
if (node.selector.slice(0, 7) === ":import") { | ||
const matches = importPattern.exec(node.selector); | ||
|
||
if (matches) { | ||
const path = matches[1].replace(/'|"/g, ""); | ||
const extra = matches[2] ? matches[2] : ""; | ||
const dep = `"${path}"${extra ? ` ${extra}` : ""}`; | ||
icssImports[dep] = Object.assign(icssImports[dep] || {}, _objectSpread({ | ||
path | ||
}, extra ? { | ||
extra | ||
} : {}, { | ||
tokens: Object.assign(icssImports[dep] ? icssImports[dep].tokens : {}, getDeclsObject(node)) | ||
})); | ||
|
||
if (removeRules) { | ||
node.remove(); | ||
} | ||
} | ||
} | ||
|
||
if (node.selector === ":export") { | ||
Object.assign(icssExports, getDeclsObject(node)); | ||
|
||
if (removeRules) { | ||
node.remove(); | ||
} | ||
} | ||
} | ||
}); | ||
return { | ||
icssImports, | ||
icssExports | ||
}; | ||
}; | ||
|
||
var _default = extractICSS; | ||
exports.default = _default; |
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,39 @@ | ||
"use strict"; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "replaceValueSymbols", { | ||
enumerable: true, | ||
get: function get() { | ||
return _replaceValueSymbols.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "replaceSymbols", { | ||
enumerable: true, | ||
get: function get() { | ||
return _replaceSymbols.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "extractICSS", { | ||
enumerable: true, | ||
get: function get() { | ||
return _extractICSS.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "createICSSRules", { | ||
enumerable: true, | ||
get: function get() { | ||
return _createICSSRules.default; | ||
} | ||
}); | ||
|
||
var _replaceValueSymbols = _interopRequireDefault(require("./replaceValueSymbols.js")); | ||
|
||
var _replaceSymbols = _interopRequireDefault(require("./replaceSymbols.js")); | ||
|
||
var _extractICSS = _interopRequireDefault(require("./extractICSS.js")); | ||
|
||
var _createICSSRules = _interopRequireDefault(require("./createICSSRules.js")); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
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,25 @@ | ||
"use strict"; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
|
||
var _replaceValueSymbols = _interopRequireDefault(require("./replaceValueSymbols.js")); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
const replaceSymbols = (css, replacements) => { | ||
css.walk(node => { | ||
if (node.type === "decl") { | ||
node.value = (0, _replaceValueSymbols.default)(node.value, replacements); | ||
} else if (node.type === "rule") { | ||
node.selector = (0, _replaceValueSymbols.default)(node.selector, replacements); | ||
} else if (node.type === "atrule" && ["media", "supports"].includes(node.name.toLowerCase())) { | ||
node.params = (0, _replaceValueSymbols.default)(node.params, replacements); | ||
} | ||
}); | ||
}; | ||
|
||
var _default = replaceSymbols; | ||
exports.default = _default; |
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,25 @@ | ||
"use strict"; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
const matchValueName = /[$]?[\w-]+/g; | ||
|
||
const replaceValueSymbols = (value, replacements) => { | ||
let matches; | ||
|
||
while (matches = matchValueName.exec(value)) { | ||
const replacement = replacements[matches[0]]; | ||
|
||
if (replacement) { | ||
value = value.slice(0, matches.index) + replacement + value.slice(matchValueName.lastIndex); | ||
matchValueName.lastIndex -= matches[0].length - replacement.length; | ||
} | ||
} | ||
|
||
return value; | ||
}; | ||
|
||
var _default = replaceValueSymbols; | ||
exports.default = _default; |
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.
NEED RETURN before release (require for fast migration and testing)