Open paulbalomiri opened 8 years ago
OK, i really need this, and as i now found out, the package load order is
Thus it is impossible to access the json from a package earlier than at Meteor.startup
time.
EDIT: This is because the earliest i get to use Assets
at the app level are when all packages are loaded.
Therefor i created a package to be copied into the /packages directory together with the json. kitchen-settings.zip
the package contains
/
package.js
kitchen-settings.js
application.json -- This needs to be generated/copied here
To use the package unzip it at <FILES_LOCATION>
Add these copy_file
directives:
"copy_files": [
{
"source": "application.json",
"dest": "OUTPUT_DIR/packages/kitchen-settings/application.json"
},
{
"source": "files/kitchen-settings/kitchen-settings.js",
"dest": "OUTPUT_DIR/packages/kitchen-settings/kitchen-settings.js"
},
{
"source": "files/kitchen-settings/package.js",
"dest": "OUTPUT_DIR/packages/kitchen-settings/package.js"
}
]
application.json
may vary./files
directory where the current directory is
the directory above the generated files (where you run meteor-kitchen
)<your dependent package>
to 'kitchen-settings'. (Note there is no developer prefix, as it is a generated - app-specific package)app_json.application
app_json.isReady()
which will be true when the json has been sent over the wire.app_json.application
by using app_json.get()app_json.isReady()
and app_json.get()
are reactive.just create a dependency on kichen-settings
, then use app_json
,which has the same structure as the json read from the application.json
file.
@perak is there any chance of getting this in the next version?
Basically it's just default copy directives for the two files and automatic write of the application.json into packages/kitchen-settings/application.json
?
Would you consider adding the json content to the
/private
folder and either or bothKitchen.loadAppJson
?This way packages could use the app json to provide additional functionality at runtime.
Anyone needing a simple solution to this can structure the project like this:
with
read_app.js
:and a
copy_files
directive:The reason i am proposing this is that if you want to add packages to the app providing kitchen-configuration related features there is no way to access the json from a reliable point.
Also putting the
Assets.getText
in thelib
Folder makes JSON loading precede package loading which is a must if you have to generate stuff the appcode relies upon beforeMeteor.startup
time.ATM if you wanted to use an external package with meteor kitchen and rely on the JSON you would have to supply above explanation and related instructions to users of the package.