-
Notifications
You must be signed in to change notification settings - Fork 7
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
User natives #206
Open
lgassman
wants to merge
24
commits into
master
Choose a base branch
from
user-natives
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
User natives #206
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
a6dd72c
add test to work
lgassman 45ffb98
Removed submodule reference
lgassman 5de08e5
Removed submodule reference
lgassman d82c6ff
partial commit
lgassman 973aeb4
read natives in tests
lgassman d1ffb70
Options refactor
lgassman 7d0a59d
fix path assertions
lgassman 55106f0
set folder as part of options
lgassman b3dcb4b
fix init call
lgassman e3ffc1e
add natives to package.json
lgassman 2f9c7ad
add Options class to REPL
lgassman 429df79
use base options on repl
lgassman f6fb2b2
run options
lgassman 2cb3d02
add natives options to init
lgassman b213aa8
fix run
lgassman 2529174
use typescript in runtime
lgassman d611fd8
revert BaseOptions to use type
lgassman e707152
read natives project inside
lgassman 79c9622
dependency command
lgassman bb67551
dolarito
lgassman fe89030
change dependecy command name and add log to .gitignore
lgassman 0d7eb58
restore wollok-ts dependency
lgassman 6f1dd1b
restore package.json
lgassman d81b75e
remove unused features of project
lgassman 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 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 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 |
---|---|---|
|
@@ -3,4 +3,8 @@ | |
.history | ||
|
||
# Wollok Log | ||
log | ||
*.log | ||
|
||
# Dependencies | ||
node_modules |
7 changes: 7 additions & 0 deletions
7
examples/user-natives/myNativesFolder/myPackage/myInnerFile.js
This file contains 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,7 @@ | ||
const packageModel = { | ||
*nativeTwo(self) { | ||
return yield* this.reify(2) | ||
}, | ||
} | ||
|
||
module.exports = { packageModel }; |
This file contains 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,7 @@ | ||
const myModel = { | ||
*nativeOne(this: any, _self: any): any { | ||
return yield* this.reify(1) | ||
}, | ||
} | ||
|
||
export { myModel } |
This file contains 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,3 @@ | ||
object packageModel { | ||
method nativeTwo() native | ||
} |
This file contains 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,8 @@ | ||
import myPackage.myInnerFile.packageModel | ||
import rootFile.myModel | ||
|
||
program myProgram { | ||
|
||
console.println(myModel.nativeOne()) | ||
console.println(packageModel.nativeTwo()) | ||
} |
This file contains 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,9 @@ | ||
{ | ||
"name": "user-natives", | ||
"version": "1.0.0", | ||
"resourceFolder": "assets", | ||
"wollokVersion": "4.0.0", | ||
"author": "leo", | ||
"license": "ISC", | ||
"natives": "myNativesFolder" | ||
} |
This file contains 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,3 @@ | ||
object myModel { | ||
method nativeOne() native | ||
} |
This file contains 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,7 @@ | ||
import rootFile.myModel | ||
import myPackage.myInnerFile.packageModel | ||
|
||
test "call a native method used by user" { | ||
assert.equals(1, myModel.nativeOne()) | ||
assert.equals(2, packageModel.nativeTwo()) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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,28 @@ | ||
import { execSync } from 'child_process' | ||
import path from 'path' | ||
import logger from 'loglevel' | ||
|
||
export type Options = { | ||
project: string | ||
verbose: boolean | ||
} | ||
|
||
const executeNpmCommand = (command: string, project: string, verbose: boolean): void => { | ||
const fullCommand = `npm ${command}` | ||
if (verbose) { | ||
logger.info(`Executing in ${project}: ${fullCommand}`) | ||
} | ||
execSync(fullCommand, { cwd: path.resolve(project), stdio: 'inherit' }) | ||
} | ||
|
||
export const addDependency = (pkg: string, { project, verbose }: Options): void => { | ||
executeNpmCommand(`install ${pkg}`, project, verbose) | ||
} | ||
|
||
export const removeDependency = (pkg: string, { project, verbose }: Options): void => { | ||
executeNpmCommand(`uninstall ${pkg}`, project, verbose) | ||
} | ||
|
||
export const synchronizeDependencies = ({ project, verbose }: Options): void => { | ||
executeNpmCommand('install', project, verbose) | ||
} |
This file contains 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 |
---|---|---|
|
@@ -13,11 +13,13 @@ export type Options = { | |
noTest: boolean, | ||
noCI: boolean, | ||
game: boolean, | ||
noGit: boolean | ||
noGit: boolean, | ||
natives?: string | ||
} | ||
|
||
export default function (folder: string | undefined, { project: _project, name, noTest = false, noCI = false, game = false, noGit = false }: Options): void { | ||
export default function (folder: string | undefined, { project: _project, name, noTest = false, noCI = false, game = false, noGit = false, natives = undefined }: Options): void { | ||
const project = join(_project, folder ?? '') | ||
const nativesFolder = join(project, natives ?? '') | ||
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. si me pasaron natives, entonces es esa carpeta, si no es la misma del project |
||
|
||
// Initialization | ||
if (existsSync(join(project, 'package.json'))) { | ||
|
@@ -28,6 +30,7 @@ export default function (folder: string | undefined, { project: _project, name, | |
|
||
// Creating folders | ||
createFolderIfNotExists(project) | ||
createFolderIfNotExists(nativesFolder) | ||
createFolderIfNotExists(join(project, '.github')) | ||
createFolderIfNotExists(join(project, '.github', 'workflows')) | ||
if (game) { | ||
|
@@ -52,7 +55,7 @@ export default function (folder: string | undefined, { project: _project, name, | |
} | ||
|
||
logger.info('Creating package.json') | ||
writeFileSync(join(project, 'package.json'), packageJsonDefinition(project, game)) | ||
writeFileSync(join(project, 'package.json'), packageJsonDefinition(project, game, natives )) | ||
|
||
if (!noCI) { | ||
logger.info('Creating CI files') | ||
|
@@ -130,16 +133,16 @@ program PepitaGame { | |
} | ||
` | ||
|
||
const packageJsonDefinition = (projectName: string, game: boolean) => `{ | ||
const packageJsonDefinition = (projectName: string, game: boolean, natives?: string) => `{ | ||
"name": "${basename(projectName)}", | ||
"version": "1.0.0", | ||
${game ? assetsConfiguration() : ''}"wollokVersion": "4.0.0", | ||
"author": "${userInfo().username}", | ||
"author": "${userInfo().username}",${nativesConfiguration(natives)} | ||
"license": "ISC" | ||
} | ||
` | ||
|
||
const assetsConfiguration = () => `"resourceFolder": "assets",${ENTER} ` | ||
const nativesConfiguration = (natives?: string) => natives ? `${ENTER} "natives": "${natives}",` : '' | ||
|
||
const ymlForCI = `name: build | ||
|
||
|
@@ -170,5 +173,9 @@ const gitignore = ` | |
.history | ||
|
||
# Wollok Log | ||
log | ||
*.log | ||
|
||
# Dependencies | ||
node_modules | ||
` |
Oops, something went wrong.
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.
A estos no hay que mandarles
-s
para que queden guardados en el package.json?