Permalink
Browse files

Tranform php.js into Locutus (#291)

a few of the things I have been working on in order to clean up our codebase and breathe new life into this project:

- Added (generated) Mocha tests for every function, instead of our own test framework
- Added a `$global` that works in both Browsers and Node.js (we should try to avoid this when we can though)
- Added a CONTRIBUTORS guide as well as New Issue and Pull Request templates, so we can be more efficient using GitHub
- Added native JSON, base64, sha1 and md5 support where available
- Added npm versioning and releases
- Added support for ES6, any function can be written in this JavaScript version and it will be transpiled to ES5 before we publish to npm to ensure compatability.
- Asked [Troy Dodd](http://troydodd.deviantart.com/art/Locutus-of-Borg-217586598) if we could use his stunning Locutus artwork to be our avatar (and he said yes!)
- Assimilated a dozen of example functions that showcase how we could port four new languages to JavaScript
- Changed all functions to make them adhere to the [JavaScript Standard Style](http://standardjs.com/) and have a max line length of 100. Travis CI will fail when new additions do not adhere
- Deprecated/documented all functions using `eval`, `new Function` and other bad practices
- Fixed  around 50 failed tests that were previously marked as skipped (still a few to go)
- Made it so that all functions can be required individually via npm
- Made it so that dependencies between functions are now handled via CommonJS `require`
- Moved the website from Jekyll to Hexo, so that we lose a Ruby dependency and everything needed to work on the website can be `npm install`ed
- Refactored the utility class
- Removed `_workbench` and `_experimental` folders. They are available for reference in 1.3.2, but making them harder to find for newcomers should help avoid complaints and confusion. If you want to experiment, we can use local files or branches when it's time to collaborate.
  • Loading branch information...
1 parent c57a814 commit 18e21b2301f130b89a22f8f35ec59466c5c840d7 @kvz committed May 2, 2016
Showing 2,651 changed files with 74,391 additions and 419,857 deletions.
View
@@ -0,0 +1 @@
+{ "presets": ["es2015"] }
View
@@ -1,14 +1,11 @@
{
"extends": "standard",
+ "rules": {
+ # "max-len": ["error", {"code": 100, "ignoreUrls": true, "ignorePattern": "(^module\\.exports|.+\\.\\./info/ini_get.+|^ //\\s+_?(returns|example))" }]
+ },
"env": {
+ "mocha": true,
"browser": true,
"node": true
- },
- "rules": {
- "no-undef": 0,
- "no-unused-vars": 0,
- "no-eval": 0,
- "key-spacing": 0,
- "one-var": 0
}
}
@@ -0,0 +1,3 @@
+- [ ] Have you checked the guidelines in our [Contributing](https://github.com/kvz/locutus/blob/master/CONTRIBUTING.md) document?
+
+### Description
@@ -0,0 +1,4 @@
+- [ ] Have you followed the guidelines in our [Contributing](https://github.com/kvz/locutus/blob/master/CONTRIBUTING.md) document?
+- [ ] Have you checked to ensure there aren't other open [Pull Requests](https://github.com/kvz/locutus/pulls) for the same update/change?
+
+### Description
View
@@ -1,5 +1,5 @@
tools/_temp/*
-build/
+dist/
nbproject
.project
.gitup.dat
@@ -18,3 +18,7 @@ website/assets/bower/
website/assets/build/
website/vendor/cache/
website/.jekyll-metadata
+scripts/main.js
+scripts/split-*.js
+scripts/main.js.map
+website/public
View
@@ -0,0 +1,22 @@
+{
+ "indent_size": 2,
+ "indent_char": " ",
+ "eol": "\n",
+ "indent_level": 0,
+ "indent_with_tabs": false,
+ "preserve_newlines": true,
+ "max_preserve_newlines": 2,
+ "jslint_happy": true,
+ "space_after_anon_function": true,
+ "brace_style": "collapse",
+ "keep_array_indentation": false,
+ "keep_function_indentation": false,
+ "space_before_conditional": true,
+ "break_chained_methods": false,
+ "eval_code": true,
+ "unescape_strings": false,
+ "wrap_line_length": 120,
+ "wrap_attributes": "auto",
+ "wrap_attributes_indent_size": 2,
+ "end_with_newline": true
+}
View
@@ -1,3 +0,0 @@
-_octopress
-experimental
-workbench
View
@@ -3,22 +3,20 @@ node_js:
- 4.4.2
- 0.12
- 0.10
- - 0.8
sudo: false
matrix:
allow_failures:
- node_js: 4.4.2
- node_js: 0.12
- - node_js: 0.8
-addons:
- apt:
- sources:
- - ubuntu-toolchain-r-test
- packages:
- - gcc-4.8
- - g++-4.8
- - php5-cli
+# addons:
+# apt:
+# sources:
+# - ubuntu-toolchain-r-test
+# packages:
+# - gcc-4.8
+# - g++-4.8
+# - php5-cli
script:
- - npm run lint || true
+ - npm run lint
- npm run build
- npm run test
View
@@ -0,0 +1,92 @@
+# Changelog
+
+Our combined changelog and roadmap. It contains todos as well as dones.
+
+Only project-wide changes are mentioned here. For individual function changelogs, please refer to their
+respective Git histories.
+
+Locutus does not follow SemVer as we're a work in progress, and even though we try,
+we cannot guarantee BC-safety for the hundreds of contributions across the many l
+anguages that Locutus is assimilating.
+
+Instead, we recommend using version pinning, and inspect changes for the few particular functions you rely on
+when you upgrade.
+
+## Backlog
+
+Ideas that will be planned and find their way into a release at one point
+
+- [ ] Have _one_ way of checking pure JS arrays vs PHP arrays (vs: `Object.prototype.toString.call(arr1) === '[object Array]'`, `typeof retObj[p] === 'object'`, `var asString = Object.prototype.toString.call(mixedVar) var asFunc = _getFuncName(mixedVar.constructor) if (asString === '[object Object]' && asFunc === 'Object') {` )
+- [ ] Compare example test cases for PHP against `php -r` to make sure they are correctly mimicking the most recent stable behavior
+- [ ] Investigate if we can have one helper function for intersecting, and use that in all `array_*diff*` and `array_*sort*` functions. Refrain from using `labels`, as those functions currently still rely on
+- [ ] Investigate if we can have one helper function for sorting, and use that in all `*sort*` functions
+- [ ] Investigate if we can have one helper function to resolve `Function/'function'/'Class::function'/[$object, 'function']`, and use that in `is_callable`, `array_walk`, `call_user_func_array` etc.
+- [ ] Port a few more tricky/inter-depending Ruby functions
+- [ ] Port a few more tricky/inter-depending Python functions
+- [ ] Port a few more tricky/inter-depending Go functions
+- [ ] Parse `require`s with AST just like Browserify does. Then we can add dependencies back to website
+
+## v2.0.1
+
+Released: Not yet
+
+- [ ] Triage all open issues and PRs via waffle.io
+- [ ] Auto-deploys of `master` to http://locutusjs.io via Travis CI
+- [ ] Address the 25 remaining test failures that are currently skipped (find out which ones via `npm run test:languages:noskip`)
+- [ ] website: Add social buttons
+- [ ] website: Render authors server-side
+
+## v2.0.0
+
+Released: Not yet
+
+- [x] website: Add profile to sidebar
+- [x] Rename `_locutus_shared` to `_helpers`. Rename `_locutus_shared_bc` to `_bc`
+- [x] website: Fix jumpy scrolling due to on the githubs
+- [x] website: DRY up add_more code
+- [x] website: About as homepage
+- [x] Transpile to ES5 before publishing to npm
+- [x] Add `estarget` option to all functions, set `ip2long` to `es2015`
+- [x] Change `fix(me)?` and `Todo` to `@todo`
+- [x] Replace single line `/**/` comments with `//`
+- [x] Enforce a 100 character line-length via eslint, and change all functions accordingly
+- [x] Do not pass values by reference via the `window` global, use e.g. `countObj.value` and `errorObj.value` instead
+- [x] Have _one_ way of getting an `ini` value and its default
+- [x] Track all cases of `setTimeout`, use them without window prefix. Remove `codez` replace hack
+- [x] Track all cases of XMLHttpRequest
+- [x] Test `is_array` in-browser to see if the `require` for `ini_get` works correctly with Browserify
+- [x] Deprecate blocking ajax requests in e.g. `file_get_contents`
+- [x] Use native `sha1` and `md5` encoding when available
+- [x] Remove XUL from functions
+- [x] Rename `strictForIn` to `sortByReference`
+- [x] Remove `// (BEGIN|END) (STATIC|REDUNDANT)`
+- [x] Index all `note`s
+- [x] Either deprecate or document all functions using `eval` or `new Function`
+- [x] Port Util to ES6 class
+- [x] Write one function (`ip2long`) in ES6 and make it pass tests & linting
+- [x] Deprecate support for node_js: 0.8
+- [x] Make Travis fail on eslint issues
+- [x] Move CHANGELOG to own file
+- [x] Make all functions pass eslint with JavaScript Standard Style
+- [x] Remove `_workbench` and `_experimental`. They are available for reference in `1.3.2` but making them harder to find for newcomers should help avoid a lot of complaints
+- [x] Move functions that overly rely on ini & locales & global & ajax file operations to \_legacy
+- [x] Address ~50 test failures that were previously skipped and now enabled
+- [x] `json_*` functions can leverage Node's
+- [x] Add ES6 capabilities
+- [x] Adopt better global detection, use `$locutus.golang.<specifics>`
+- [x] Add more 'social' buttons to website (twitter, github)
+- [x] Rework injectweb after structural changes in util.js
+- [x] Use `require` for dependencies
+- [x] Remove `;` from examples in accordance with JavaScript Standard Style
+- [x] Use mocha for generating language tests
+- [x] Use require for dependencies
+- [x] In util.opener: First `*` should point to the requesting/current language
+- [x] Split out the npm module so you could do `var sprintf = require('locutus/sprintf')`
+- [x] Launch BC breaking blogpost
+- [x] Roll out support for Ruby, C, Go, Python
+
+## v1.3.2
+
+Released: April 4, 2016
+
+- [x] Start using a CHANGELOG https://github.com/kvz/phpjs/releases/tag/v1.3.2
View
@@ -1,10 +1,17 @@
-Thank you so much for becoming a php.js contributor!
+Thank you so much for becoming a Locutus contributor!
+
+Even if you have write access, all code changes should be done via a pull request. This way
+we can peer-review, and also Travis CI can check if the code adheres to our policies before
+merging it in.
Here are a few pointers that could save us from disappointment, we'll keep it brief:
-1. By submitting a Pull Request you are giving php.js permission to distribute your code under the MIT License.
-1. Please adhere to our [coding standards](/blog/2016/04/01/standard-coding-style/).
-1. Please credit yourself in the function's header-comment: `(original by|improved by|bugfixed by|revised by|input by): Your Name (http://your.url)`
-1. If you're fixing bad behavior, please add an `example` that would fail before your patch, and a `result` that passes after your patch, to the function's header-comment
-1. Since we are mimicking PHP, our `array_` functions need to accept Objects, which is the closest thing to the hash-table like data-structure that PHP calls an array. Please keep this in mind as you're proposing optimizations.
-1. Sometimes we place `for` inside `if` for performance reasons, even if the code could be twice as small if we did this the other way around.
+1. By submitting a Pull Request you are giving Locutus permission to distribute your code under the MIT License.
+1. Please adhere to our [updated coding standards](/blog/2016/04/standard-coding-style/). Use `npm run lint` to check. Code should:
+ - Follow the [JavaScript Standard Style](http://standardjs.com/)
+ - Not have lines longer than 100 chars
+ - Use `//` for comments instead of `/*`
+ - Avoid using lengthy (3+ words) comments on the same line as code
+1. Please credit yourself in the function's header-comment: `(original by|reimplemented by|improved by|parts by|bugfixed by|revised by|input by): Your Name (http://your.url)`
+1. If you are fixing bad behavior, please add an `example` that would fail before your patch, and a `result` that passes after your patch, to the function's header-comment
+1. Sometimes we place `for` inside `if` for performance reasons, even though the code could be half the size if we did this the other way around.
View
@@ -0,0 +1,20 @@
+Copyright (c) 2007-2016 Kevin van Zonneveld (http://kvz.io)
+and Contributors (http://locutusjs.io/authors)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
View
@@ -1,20 +0,0 @@
-Copyright (c) 2007 Kevin van Zonneveld (http://kvz.io)
-and Contributors (http://phpjs.org/authors)
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
Oops, something went wrong.

0 comments on commit 18e21b2

Please sign in to comment.